Course / Tutorials / Week 2 / Q-5
Quick tutorial Q-5 · Week 2 · about 15 min · Foundation
Fit a straight line and read the slope's units
Fit heart rate against step-test workload with least squares, state the slope in beats a minute per watt and per step cycle, and see why the line's intercept is not the resting heart rate.
- Ask
- Collect
- Check (this week)
- Interpret (this week)
- Coach
- Reassess
Download notebook ·Python file ·Read as Markdown ·Data folder ·Chapter 2 (sections 2.11)
Every cell runs in this page; the first run downloads Python (about 30 s). Nothing you load leaves your browser. Helpful first: Q-4 Type a small table and plot it.
The decision
An athlete wants to know how much harder her heart works for each step up in effort. The answer is a slope, and it is only useful with its units and the range it was measured over.
The raw data
raw/steptest_counts.csv: pulse counts after three step-test stages and in recovery, with the lifting power of each stage (synthetic). Data-Driven Athletics, Chapter 2, Section 2.11: Sam's step test, synthetic data made by the chapter's script.
Try it
Heart rate against workload
Over the middle of its range, heart rate rises almost in a straight line with how hard you work (Section 2.11). Sam's step test gives three points: the lifting power of each stage, in watts, and the heart rate counted after it. Sam is a made-up student and the data are the book's synthetic step test. Fit the straight line HR = a + b × P by least squares: the line that makes the squared vertical misses as small as possible.
Type a prediction to enable Run.
Show the expected result without running
label rate_cpm power_W hr_bpm stage 1 15 51.5 96 stage 2 20 68.7 108 stage 3 25 85.8 124 HR = 53.3 bpm + 0.816 bpm/W x P
Read the slope with its units
The slope is 0.816, and without units it means nothing. Heart rate is in beats a minute and power in watts, so the slope is beats a minute per watt. The same line can be written per step rate: one more step cycle a minute lifts 70 kg up 0.30 m once more a minute, which is 3.43 W. The intercept has units too, beats a minute, and it is the line's value at zero watts.
Show the expected result without running
one cycle a minute = 3.43 W -> slope 2.80 bpm per cycle/min 10 W more -> 8.2 bpm more at 22 cycles/min (75.5 W) the line predicts 115 bpm intercept 53.3 bpm at 0 W; Sam's resting heart rate on the strap before the test: about 64 bpm
Each watt adds about 0.8 beats a minute; each extra step cycle a minute adds about 2.8. A stage at 22 cycles a minute, between the second and third, should bring Sam to about 115. But the intercept, 53 at zero watts, is below Sam's resting heart rate of about 64. A line fitted between 51 and 86 W says nothing reliable outside that range; heart rate at rest is not on it. (The resting value comes from the strap's record of the same test, used in Q-6.)
One chart
Show the expected result without running
residuals (bpm): [ 0.7 -1.4 0.7]

The line fits the three stages to within 1.4 beats a minute. That is less than the 4-beat steps a 15-second count can resolve, so do not read much into how well three points fit; CS-2 tests a line on a stage it has not seen.
For the athlete: "In this test each step faster per minute raised your heart rate by about 3 beats; that holds between the slowest and fastest stages we tried, not outside them."
With your own data
Replace the three stages with your own counts, lifting power from your own body mass and bench height, and read your slope in beats a minute per watt. Two people's slopes can only be compared if both used the same bench and step rates.
Check yourself
A line fitted to heart rate (beats/min) against power (W) has slope 0.8. What are its units?
With HR = 53.3 + 0.816 × P, what heart rate does the line predict at 80 W?
The intercept is 53 bpm, but the athlete's resting heart rate is about 64. What does that mean?
References
- Data-Driven Athletics, Chapter 2, Measuring Yourself: A Step Test (Section 2.11), the engineer's note on your first straight-line fit.
Built 2026-11-30 with Python packages numpy 2.5.5, pandas 3.1.1, matplotlib 3.11.2. In the browser the same code runs on Pyodide, so the last digit can differ.