pub struct Rng { /* private fields */ }Expand description
A SplitMix64 generator. Fast, good statistical quality, single-word state.
Implementations§
Source§impl Rng
impl Rng
Sourcepub fn split(seed: u64, id: u64) -> Self
pub fn split(seed: u64, id: u64) -> Self
Derives an independent generator for parallel stream id.
The child seed is mix_seed(seed, id), so different (seed, id)
pairs give non-overlapping sub-streams deterministically — the basis for
reproducible island/ensemble parallelism.
Sourcepub fn uniform_in(&mut self, lo: f64, hi: f64) -> f64
pub fn uniform_in(&mut self, lo: f64, hi: f64) -> f64
Uniform f64 in [lo, hi] (the top end is reachable: lo + (hi−lo)·u
with u half an ulp below 1 can round up to hi, which is fine for
the inclusive bounds used throughout the crate).
Sourcepub fn index(&mut self, bound: usize) -> usize
pub fn index(&mut self, bound: usize) -> usize
usize uniform in [0, bound).
Uses a plain modulo reduction: the bias is ~bound/2⁶⁴ (immeasurable
for the population/dimension sizes used here) and, unlike rejection
sampling, it consumes exactly one draw — which keeps RNG consumption,
and therefore byte-level reproducibility, independent of bound.
§Panics
If bound == 0.