Module 9Random NumbersLesson 6 of 822 min
Seedable LCG Uniforms
Educational RNG: reproducibility and (0,1) mapping.
Why seed?
Same seed => same MC paths — essential for tests and debugging.
LCG
state = a*state + c (mod 2^64 via wrapping)
Production
Use rand + rand_chacha offline; LCG is for learning.
Challenge
Show two RNGs with same seed produce identical streams.
Tips
- wrapping_* prevents panic
- Avoid 0 for ln later
- Seeds enable tests
Try it live
Seedable LCG UniformsRust 2021
Loading editor…
Output
Press Run to compile and execute.