Given a vector of integers
a = collect(1:10)
I would like to randomly sample 5 integers with guaranteed non-repetition. As far as I know,
b = rand(a, 10)
does not guarantee that. This is easily demonstrated via
for i in 1:100 println(rand(1:10, 8)) end
How can it be done? Thanks.
I found the answer on Slack: https://stackoverflow.com/questions/36047516/julia-generating-unique-random-integer-array
StatsBase.rand(using StatsBase a = sample(1:100, 10, replace = false)
rand has 173 functions in its dispatch table, that adding a
replace argument` in several of them could prove very useful.