Closed
Description
openedon May 11, 2013
I think a useful utility function is to chose a random element from an array. Python has this in random.choice. Here is what a Julia implementation might look like:
function choice(a::Array)
n = length(a)
idx = mod(rand(Uint),n)+1
return a[idx]
end
An option would be to have an additional argument for drawing some number of samples. This would be sampling with replacement from an array with uniform probability.
Another useful function could be to have sampling without replacement.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
No labels