Module rand::seq::index

source ยท
Expand description

Low-level API for sampling indices

Enumsยง

Traitsยง

Functionsยง

  • Randomly sample exactly amount distinct indices from 0..length, and return them in random order (fully shuffled).
  • Randomly sample exactly amount distinct indices from 0..length, and return them in an arbitrary order (there is no guarantee of shuffling or ordering). The weights are to be provided by the input function weights, which will be called once for each index.
  • sample_floyd ๐Ÿ”’
    Randomly sample exactly amount indices from 0..length, using Floydโ€™s combination algorithm.
  • sample_inplace ๐Ÿ”’
    Randomly sample exactly amount indices from 0..length, using an inplace partial Fisher-Yates method. Sample an amount of indices using an inplace partial fisher yates method.
  • sample_rejection ๐Ÿ”’
    Randomly sample exactly amount indices from 0..length, using rejection sampling.
  • Randomly sample exactly amount distinct indices from 0..length, and return them in an arbitrary order (there is no guarantee of shuffling or ordering). The weights are to be provided by the input function weights, which will be called once for each index.