Experiment as a Script

An experiment script should have a clear workflow.

For this subject, a useful shape is:

configuration -> data -> computation -> plot -> summary

That shape can live in a main function.

Each function has one job. The script reads like a short report.

Keep configuration visible

Use a dataclass for values that define the run:

Script-shaped experiment

Runs locally with Python in your browser.

Ready to run.

The config is not hidden inside the computation. A reader can see the run conditions immediately.

Why script shape matters

An experiment script should be:

  • rerunnable;
  • inspectable;
  • easy to change in one place;
  • easy to compare with another run.

If a script is just one long block, it becomes hard to see what is data creation, what is computation, and what is reporting.

Exercise: Workflow order

Which order best describes the experiment script shape used here?

Choose one

Select one choice, then check.

Hint

Define the run first, then create and analyze data, and record the result last.

Solution

The workflow is configuration → data → computation → plot → summary. It makes the run conditions visible before the result and preserves the evidence at the end.