Your first simulationLesson 05 of 76 · 6 min

Reproduce a random run

Use seeds without confusing reproducibility with independent replication.

A pseudo-random generator produces a deterministic sequence from an initial state. A seed makes that state reproducible. Record the generator, package version, seed and draw order when you need someone else to recreate a calculation.

Two generators initialised with the same seed produce the same sequence under the same implementation. They are useful for replaying an experiment, but are not independent replications. Changing the sequence of calls changes which draws enter each calculation.

A fresh seed can reveal numerical variation under the same model. It cannot reveal assumptions omitted from that model. For parallel work, independent child streams, separate pseudo-random sequences, provide a principled alternative to repeatedly reusing one seed; the reproducibility module returns to that design.

Replay is not a new replication
  1. Same seed + operations

    same random sequence

  2. Replay the calculation

    same estimate

  3. Independent replication

    a fresh random stream

Reference illustration. A replay checks computational reproducibility. It does not supply another independent estimate; changing the sequence of random calls can also change later draws.

Do two generators with the same seed provide two independent sets of evidence?

Write a prediction (optional)

Seeded teaching simulation

Select Run Python below with the code unchanged.

Tools
About Python ↗

The code is editable. Press Ctrl+Enter or ⌘+Enter to run Python from the editor.

Published example output

This result comes from the original Python. Your runs appear above. Build environment ↗

Original: [74 84 10 16 45 55 76 36]
Replay: [74 84 10 16 45 55 76 36]
Different seed: [89 39 21 71 86 28 36  8]
Replay identical: True

Read the first result

Compare the arrays in Original and Replay and read Replay identical. Those generators used the same seed. The Different seed row uses seed 18.

Try an edit

Add replay.integers(0, 100) immediately before b = replay.integers(0, 100, 8). Select Run Python again. Compare Original with Replay and read Replay identical. Why does the extra call change the replay even though its seed stays 17?

Back to the Python editor

Scope. Identical seeds alone do not guarantee identical results across changed generators, package versions or draw ordering.

Try a fresh case

A colleague reruns your exact seeded simulation and obtains the same output. What was checked?

Choose an answer
Need a hint?
Hint 1

Ask what changed between the two runs.

Hint 2

Distinguish replaying a sequence from obtaining a new one.

Your notes