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.
- Repeated-key model
- Fixed-setup model
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
A saved draft is open. To run the published example, open Editor tools and select Restore example. Recover draft brings your code back.
Execution error
Technical error details
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?
Your result
Result tools
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.
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.]
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?
Hints for this question
- Ask where the predictions separate.
- Choose the condition before observing which result you prefer.