Skip to main content

Module random

Module random 

Source
Expand description

Random number generation, shuffling, and weighted sampling.

Provides seeded RNG construction, Fisher-Yates shuffle, and weighted random sampling utilities.

§Reproducibility

For reproducible experiments, use create_rng with a fixed seed. The underlying algorithm (SmallRng) is deterministic for a given seed on the same platform.

Structs§

WeightedSampler
Pre-computed weighted sampler for O(log n) repeated sampling.

Functions§

create_rng
Creates a fast, seeded random number generator.
shuffle
Fisher-Yates (Durstenfeld) in-place shuffle.
shuffled_indices
Returns a shuffled index permutation of [0, n).
weighted_choose
Selects a random index weighted by the given weights.