Random Number Generation
Computers produce reproducible pseudo-random sequences from a seed, which makes stochastic methods both random enough and repeatable.
Deterministic randomness
A computer cannot produce true randomness on its own. Instead it runs a pseudo-random number generator (PRNG): a deterministic algorithm that, from a starting seed, emits a sequence that passes statistical tests for randomness. Same seed, same sequence — every time.
Why the seed matters
The seed is the key to reproducibility in any method that uses randomness. Record the seed and a Monte Carlo simulation can be rerun to the same result; lose it and the run can never be exactly reproduced. Recording seeds is therefore a basic reproducibility practice, not an optional detail.
Quality of generators
- Period: how long before the sequence repeats — must far exceed the samples used.
- Statistical quality: absence of detectable patterns and correlations.
- Reproducibility: same seed yields the same stream across runs.
A concrete example
import random
random.seed(42)
print([random.random() for _ in range(3)])
# Re-seeding with 42 reproduces the exact same three numbers
True versus pseudo
Some applications, such as cryptography, need hardware sources of true randomness. Scientific simulation deliberately prefers high-quality pseudo-randomness precisely because it is reproducible: a neutronics or Monte Carlo result for the breeder Hyperion can be regenerated exactly, error bars and all, because its random stream is fixed by a recorded seed.