Reading Code as a Report

A small experiment should read like a report.

That does not mean adding long comments. It means the structure itself tells the story:

configuration
data creation
fitting
plotting
summary

A complete small experiment

Complete noisy-line experiment

Runs locally with Python in your browser.

Ready to run.

This code has a report-like order. The final printed lines say how the run was controlled and what happened.

What good code makes easy

A reader should be able to answer:

  • What was the seed?
  • How was the data made?
  • What was searched?
  • What was measured?
  • What does the plot show?
  • What result was saved or printed?
Exercise: Report question

Which question should a reader be able to answer from a small experiment report?

Choose one

Select one choice, then check.

Hint

A report should identify the result used to compare candidate slopes.

Solution

A reader should be able to answer what was measured. Here, the search measures mean squared error and reports the lowest-loss candidate slope.