Rerunning an Experiment

Rerunning an experiment means running the same procedure again and comparing the output.

With a fixed seed, the controlled random choices repeat.

Without a fixed seed, the random choices can change.

Compare fixed and unfixed runs

Fixed seed versus no fixed seed

Runs locally with Python in your browser.

Ready to run.

The fixed rows match. The unfixed rows usually do not.

What can still vary?

A seed controls the generator's starting state. It does not make every possible environment identical. Larger experiments may also depend on:

  • library versions;
  • hardware;
  • parallel execution;
  • data files;
  • preprocessing choices.

For this Python subject, the main habit is simpler: record the seed and configuration values before comparing outputs.

Exercise: Rerun explanation

With a fixed seed and the same code, what should happen to the generated random sequence?

Choose one

Select one choice, then check.

Hint

The same seed returns a new generator to the same initial state, within the same controlled environment.

Solution

The generated sequence should repeat when the seed, code, call order, data, and relevant environment are the same. A seed alone does not control every source of variation in a larger experiment.