Skip to main content

Module rng

Module rng 

Source
Expand description

Deterministic pseudo-random generators: seeded, reproducible, not cryptographic.

Two tiny generators, each the single spelling of its algorithm in the crate:

  • SplitMix64 (Steele, Lea & Flood 2014) — the general-purpose generator behind stats::Rng, differential evolution’s seed, and the sample points of Ex::probably_equal.
  • XorShift64Star (Vigna 2016) — the generator the randomised number-theoretic and polynomial algorithms (Miller–Rabin witnesses, Pollard–Brent, Cantor–Zassenhaus splitting) draw from.

Both streams are pinned bit-for-bit by tests/v20/v20_base.rs: the algorithms decide which factor a randomised split finds first and which Monte-Carlo sample a test sees, so a change here is an output change.

Structs§

SplitMix64
SplitMix64: a fast, well-distributed 64-bit generator with a 64-bit state (Steele, Lea & Flood, “Fast splittable pseudorandom number generators”, OOPSLA 2014). Every seed gives a full-period stream.
XorShift64Star
xorshift64*: a 64-bit xorshift state whose output is scrambled by one multiplication (Vigna, “An experimental exploration of Marsaglia’s xorshift generators, scrambled”, ACM TOMS 42(4), 2016). The seed is mixed with the golden-ratio constant and a zero seed is replaced by 1, since the all-zero state is a fixed point of xorshift.