Ask a better questionLesson 02 of 30 · 5 min

Prediction before explanation

Write different observable predictions for two competing explanations.

An explanation proposes why something happens. A prediction says what you expect to observe in stated conditions. A useful explanation can produce several predictions; observing one prediction does not prove that explanation is the only possible cause.

Suppose a cache helps because requests repeat keys. Then the advantage should shrink as keys become less repetitive. A different explanation, that the new version saves a fixed setup cost, predicts a similar saving even when every key is unique.

A model is a deliberately simplified relationship. The prepared code gives the two models six repeat fractions from zero to one and calculates their expected savings. Both lines represent teaching assumptions.

Find where predictions diverge
00.250.50.751011.222.533.845Saving (ms)Repeat fraction
00.250.50.751011.222.533.845Saving (ms)Repeat fraction
  • Repeated-key model
  • Fixed-setup model
Authored prediction models, not measurements. The solid repeat-key model predicts no saving with unique keys; the dashed fixed-setup model still predicts 15 ms.

Which explanation predicts a saving when the repeat fraction is zero?

Write a prediction (optional)

Run the prepared example

This page puts the example in the Python editor. Select Run Python with the code unchanged.

Authored model

Editor tools
About Python ↗

Ctrl+Enter or ⌘+Enter runs the code.

What to compare

Find 0 in Repeat fractions, then read the first entry in Repeat model saving (ms) and Setup model saving (ms). Which explanation predicts a saving with no repeated keys?

Published example output

The site ran the original code to produce this reference. Build environment ↗

Repeat fractions: [0.  0.2 0.4 0.6 0.8 1. ]
Repeat model saving (ms): [ 0.  8. 16. 24. 32. 40.]
Setup model saving (ms): [15. 15. 15. 15. 15. 15.]
Predicted saving in milliseconds across six repeated-key fractions. The fixed-setup line stays at 15 ms while the repeated-key line rises from zero.
Open full-size figure ↗

At zero repeat fraction the repeated-key explanation predicts no saving and the fixed-setup explanation predicts 15 ms. Where the lines are close, a noisy measurement has less power to distinguish them.

Change and run again

In the Python editor, replace 15.0 with 30.0 in setup_model = np.full(6, 15.0). Select Run Python again. Use Repeat fractions and the two savings rows to find a fraction where the predictions differ. What could a measurement there distinguish? Return to the Python editor

What this example supports. The lines are explicit teaching assumptions. A match between a measurement and one line would not rule out every other explanation.

Try a fresh case

Two explanations predict the same result for a small dataset. What is the most useful next test?

Choose an answer

Hints for this question
  1. Ask where the predictions separate.
  2. Choose the condition before observing which result you prefer.
Your notes