apopt.comCBE 493R Data-Driven Athletics

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.

  1. 1Gather
  2. 2Statistics (used)
  3. 3Visualize (used)
  4. 4Cleanse
  5. 5Features
  6. 6Balance
  7. 7Scale
  8. 8Split
  9. 9Deploy
  1. Ask
  2. Collect
  3. Check (this week)
  4. Interpret (this week)
  5. Coach
  6. Reassess

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

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.

PythonFit the line

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.

PythonThe same slope in other units, and a prediction

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

PythonThe points, the line, and where the line stops being true

Show the expected result without running
residuals (bpm): [ 0.7 -1.4  0.7]
Heart rate in beats per minute against lifting power in watts. Three points at 51.5, 68.7 and 85.8 W lie close to a solid fitted line; the line is extended as a dashed line to 0 W, where it reaches 53 bpm, below a horizontal mark at the resting heart rate of 64 bpm.

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

  1. A line fitted to heart rate (beats/min) against power (W) has slope 0.8. What are its units?

  2. With HR = 53.3 + 0.816 × P, what heart rate does the line predict at 80 W?

    beats/min

  3. The intercept is 53 bpm, but the athlete's resting heart rate is about 64. What does that mean?

0 of 3 answered · 0 right the first time

References

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.