Computing Library › AI & Foundations
AI & Foundations

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

Kronos motion — which application

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

A concrete example

python
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.