Randomly samples n items the iterable uniformly, returning them in uniformly random order.
If you need to select a single item randomly from the iterable, pass n = 1.
If you need to sample items with varying weight, use sampleWeighted.
This uses a reservoir sampling algorithm.
type of the item
the iterable
the number of items to sample
random number generator
Randomly samples n items the iterable uniformly, returning them in uniformly random order.
If you need to select a single item randomly from the iterable, pass n = 1.
If you need to sample items with varying weight, use sampleWeighted.
This uses a reservoir sampling algorithm.