JuliaStats / StatsBase.jl

Basic statistics for Julia
Other
583 stars 194 forks source link

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

Open cafaxo opened 1 year ago

cafaxo commented 1 year ago

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
perrette commented 4 months ago

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