Julia-users: is there an equivalent to R's sample(x,y,prob=) to sample from a given set of values with weighted probabilities? The rand() function is equivalent to sample(x,y), but as far as I'm aware there's no option to add probability weights... Any help appreciated!
OK - done a bit more digging and wsample from the Distributions package seems to be the answer:
using Distributions
wsample(population, weights, n)
Next time I'll look harder before posting!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With