StatsBase.jl icon indicating copy to clipboard operation
StatsBase.jl copied to clipboard

`wsample(w)` behaves not as the documentation describes it

Open cafaxo opened this issue 2 years ago • 1 comments

The doc says

wsample([rng], [a], w)

Select a weighted random sample of size 1 from a with probabilities proportional to the weights given in w. If a is not present, select a random weight from w.

From this, I expect wsample(w) ∈ w. However, I am getting

julia> wsample([1,10])
2

cafaxo avatar Jul 26 '23 14:07 cafaxo

Just passing by: it does look that a sensibile behavior (sampling the weight indices) and a bad documentation. Definitely not a bug.

perrette avatar Jun 13 '24 04:06 perrette