I am using the following piece of code
using StatsBase pf = StatsBase.Weights(rand(10)) e = sample(pf)
@which sample(pf), one gets
sample(wv::StatsBase.AbstractWeights) in StatsBase at .../StatsBase/src/sampling.jl:425
for which the algorithm is super straightforward. For example, if
t in this algorithm is very close to
sum(wv), I would say it is better to go over
wv starting from the end.
Hence my question, is it possible to do something like a binary search (like
searchsorted) to do the same as
I tried and I could not.
Thank you for your help,