Seeds, Streams, and Reproducibility
Why the same code gives different answers, and how a seed turns a random study into a repeatable one.
Controls
Every result on this page is a deterministic function of the seed and the controls.
Off uses a properly spaced substream offset per worker.
Same seed, same answer
Two independent replays of the identical seed produce bit-identical estimates.
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.
Parallel streams: k workers
Naive seeding (seed = worker index) — nearby small seeds can start highly correlated streams.
| worker | seed used | first draws | π estimate |
|---|---|---|---|
| 0 | 1 | 0.627, 0.003, 0.527, 0.981, 0.968 | 3.1580 |
| 1 | 2 | 0.734, 0.325, 0.285, 0.538, 0.875 | 3.1700 |
| 2 | 3 | 0.720, 0.039, 0.456, 0.075, 0.763 | 3.1700 |
| 3 | 4 | 0.924, 0.333, 0.222, 0.082, 0.234 | 3.1300 |
Provenance
What a reviewer or collaborator needs to exactly reproduce this run.
seed=42; n=2000; generator=mulberry32; hash=877b89b9Report the seed, n, and generator alongside the estimate; the hash lets anyone verify they replayed the exact same draw sequence.
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.
