Understand: Test the Calculation, Not Just the Output
Optional arithmetic and percentage refresher — return to this activity
Copying current program output into an expected result can preserve a bug. An invariant is a property that must hold, such as the stated initial temperature. Test hand-solvable examples and boundaries independently of the implementation.
Cooling comparison: synthetic measurement pack v1
All people, records and numbers in this pack are authored teaching examples. They are not records or performance claims about real organizations.
- S1 · At minutes 0–6, authored temperatures are 80, 68, 59, 51, 45, 40, 36 °C. They simulate an experiment, not physical measurements. Each value has a stated ±1 °C reading interval for the exercise.
- S2 · Initial temperature is 80 °C; recorded room temperature is 20 °C. A simplified baseline retains 0.8 of excess temperature each minute: T(t)=A+(80−A)×0.8^t. A is assumed room temperature in °C; t is whole minutes; T is predicted °C. The exponent 0.8^t means multiplying by 0.8 once for each minute; at t=0 the factor is 1. The fraction 0.8 is supplied, not fitted on monitoring data.
- S3 · A straight line is fitted by least squares to minutes 0–3 only. Least squares minimizes summed squared training residuals. Its slope is −9.6 °C/min and intercept 78.9 °C.
- S4 · Minutes 4–6 are exposed monitoring cases outside the fitting interval, not an untouched test. Residual = observation − prediction; MAE = mean absolute residual. The reading interval is not automatically a confidence interval.
- S5 · The physical form assumes a stable environment and cooling fraction. Changed cup, airflow or room temperature can invalidate it. A line extrapolated far enough can predict below room temperature.
- S6 · The downloadable standard-library Python starter records input identity, configuration, row roles, runtime, coefficients and errors. No random step is used, so no seed is required. Exact bytes across every platform are not promised.
Worked example
At t=0 the physical model must give its initial 80 °C; at t=1 and A=20 it gives 68. A separate dataset (0,2),(1,5),(2,8) has slope 3 and intercept 2. Changing only monitoring values must not change fitted coefficients.
Your next action
Run starter tests and explain two assertions. Introduce a slope or split error in a copy, record which test catches it, then restore the correct version.
These are authored public practice cases. Retain your reasoning and uncertainty. A completed page does not establish independent proficiency.
Authored explanation · fixed examples, not a live experiment.
Choose hand-solvable cases
→Test initial conditions and split boundaries
→Inject a fault and observe the intended failure
Would your test catch a plausible bug?