rand.util #

fn sample_nr #

fn sample_nr<T>(array []T, k int) []T

sample_nr returns a sample of the array without replacement. This means the indices cannot repeat and it restricts the sample size to be less than or equal to the size of the given array. Note that if the array has repeating elements, then the sample may have repeats as well.

fn sample_r #

fn sample_r<T>(array []T, k int) []T

sample_r returns a sample of the array with replacement. This means the elements can repeat and the size of the sample may exceed the size of the array

fn shuffle #

fn shuffle<T>(mut a []T, n int)

shuffle randomizes the first n items of an array in place (all if n is 0)