# Weighted sampling algorithms not yet shipped?

**URL:** <https://discourse.julialang.org/t/weighted-sampling-algorithms-not-yet-shipped/69111>\
**Category:** General Usage\
**Tags:** question, statistics\
**Created:** [October 2, 2021, 12:09pm UTC](https://discourse.julialang.org/t/weighted-sampling-algorithms-not-yet-shipped/69111 "2021-10-02T12:09:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Naba7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/naba7/32/10203_2.png) [@Naba7](https://discourse.julialang.org/u/Naba7)\
**Post date:** [October 2, 2021, 12:09pm UTC](https://discourse.julialang.org/t/weighted-sampling-algorithms-not-yet-shipped/69111/1 "2021-10-02T12:09:32Z")

</div>

Why direct\_sample!, knuths\_sample!, alias\_sample or any of the other Weighted sampling algorithms say they are not defined? Are those functions not yet shipped?

```julia
direct_sample!(Random.GLOBAL_RNG, rand(50), Weights(rand(50)))

```

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [October 2, 2021, 12:40pm UTC](https://discourse.julialang.org/t/weighted-sampling-algorithms-not-yet-shipped/69111/2 "2021-10-02T12:40:39Z")

</div>

you want to use `StatsBase`  
[https://juliastats.org/StatsBase.jl/latest/sampling/#StatsBase.sample](https://juliastats.org/StatsBase.jl/latest/sampling/#StatsBase.sample)
