All labs

Seeds, Streams, and Reproducibility

Why the same code gives different answers, and how a seed turns a random study into a repeatable one.

Ch 1 1.4
Explorer
Foundations & Data Quality
12 mindifficulty 1/5

Controls

Seed mode
Random seed

Every result on this page is a deterministic function of the seed and the controls.

2000
4
Naive seeding (seed = worker index)

Off uses a properly spaced substream offset per worker.

Same seed, same answer

Two independent replays of the identical seed produce bit-identical estimates.

Replay A
3.14200
Replay B
3.14200
Identical?
yes
as guaranteed by determinism

A different seed (43) gives a different, equally valid estimate: 3.09800. Neither run is "more random" than the other — reproducibility is about the seed being recorded, not about the draws being predictable in advance.

Running Monte Carlo estimate of π

Grey band: 10th–90th percentile across 60 independent seeds, showing simulation error shrink with n.

2.602.8033.203.403.603.800500100015002000drawsestimate of π
this run (current seed)true π10th–90th pct across seeds

Parallel streams: k workers

Naive seeding (seed = worker index) — nearby small seeds can start highly correlated streams.

workerseed usedfirst drawsπ estimate
010.627, 0.003, 0.527, 0.981, 0.9683.1580
120.734, 0.325, 0.285, 0.538, 0.8753.1700
230.720, 0.039, 0.456, 0.075, 0.7633.1700
340.924, 0.333, 0.222, 0.082, 0.2343.1300

Provenance

What a reviewer or collaborator needs to exactly reproduce this run.

seed=42; n=2000; generator=mulberry32; hash=877b89b9

Report the seed, n, and generator alongside the estimate; the hash lets anyone verify they replayed the exact same draw sequence.

This run's estimate
3.14200
Effective seed
42
Spread (sd of estimate across seeds)
0.0390
n = 2000
Generator
mulberry32
deterministic 32-bit PRNG
“Random” does not mean “unreproducible”

A pseudo-random generator is a deterministic function of its seed: same seed, same stream of numbers, every time, on every machine. What is random is the relationship between the seed and the outcome you'd get for a different seed — not whether the computation can be repeated. Recording the seed converts a random-looking study into a repeatable one.