a pseudorandom number generator
/ SOO-doh-RAN-dum /
Suppose you need a long stream of 'random' numbers to run a simulation — but your computer is a perfectly obedient machine that does exactly what it is told and has no built-in coin to flip. How can a deterministic device produce randomness? It cannot, really. Instead it produces a sequence that only LOOKS random: each number is computed from the previous one by a fixed recipe, yet the output passes statistical tests for randomness well enough to fool the simulation. That recipe is a pseudorandom number generator.
Concretely, a PRNG holds an internal STATE s and has two rules: a transition s_{n+1} = T(s_n) that grinds the state forward, and an output map that squeezes each state into a number, usually a fraction u_n in [0, 1). You start it with an initial state called the SEED; from then on the entire stream is determined. Because the state lives in a finite set, the sequence must eventually repeat — the length before it cycles is the PERIOD, and a good generator has an astronomically long one. The two qualities that matter are statistical quality (the output should have no detectable patterns, correlations, or biases) and a long period (so a long run never wraps around and reuses numbers).
The honest word here is 'pseudo': these numbers are fully deterministic and reproducible. That is mostly a virtue — fixing the seed lets you rerun a simulation byte-for-byte to debug it or to let others reproduce your results. But it is a trap if you forget it: a poor generator with short period or hidden correlations can silently corrupt a Monte Carlo study, producing confident, wrong answers, and the bug is invisible because nothing crashes. For security work (keys, nonces) ordinary PRNGs are unsafe; you need a cryptographically secure generator whose output cannot be predicted even after seeing many samples. Notorious historically bad generators (like the old RANDU) taught the field to test generators hard before trusting them.
A tiny toy: state x_{n+1} = (5 * x_n + 3) mod 16. Seed x_0 = 7 gives 7, 6, 1, 8, 11, 10, 5, 12, 15, 14, 9, 0, 3, 2, 13, 4, then back to 7 — a full period of 16. Dividing by 16 turns each into a fraction in [0, 1). Real generators use the same idea with vastly larger moduli and far more state.
Every PRNG is a clockwork: a fixed rule turning one state into the next.
Pseudorandom numbers are NOT truly random — they are reproducible by design. Reusing one global generator with the same seed across parallel threads or repeated experiments can secretly correlate runs that you believed were independent.