JuliaStats / StatsBase.jl

Basic statistics for Julia

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SegFault with `efraimidis_a_wsample_norep!`

leoluecken opened this issue · comments

Hi, trying to use weighted sampling without replacement, I found a bug. One can crash the REPL, when trying to sample more points than contained in the weights or a vectors

using StatsBase
a = Vector(1:10)
x = Vector(1:100)
wv = ProbabilityWeights(rand(10))
StatsBase.efraimidis_a_wsample_norep!(a, wv, x)

The other function StatsBase.efraimidis_ares_wsample_norep! for the "Efraimidis-Spirakis A-Res algorithm" catches this and fails more gracefully. (What is the difference between these anyway?)