Skip to main content

Module rng

Module rng 

Source
Expand description

Stream-indexed random numbers.

Every simulation index draws from its own stream, identified by (seed, stream). Results are therefore bit-identical regardless of how the work is split across threads, and any single simulation can be replayed on its own. See docs/design/rng.md.

Structsยง

StreamRng
A reproducible random-number stream: ChaCha20 (original 64-bit counter, 64-bit nonce layout) keyed by seed, with the stream id as the nonce. Each stream has 2^64 blocks, far more than any simulation needs.