Skip to content

SegFault with efraimidis_a_wsample_norep! #877

Open
@leoluecken

Description

@leoluecken

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?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions