apopt.comCBE 493R Data-Driven Athletics

Course / Tutorials / Week 5 / Q-14

Quick tutorial Q-14 · Week 5 · about 15 min · Foundation

Heart rate from beat intervals

Turn a strap's beat-to-beat intervals into heart rate, find out why the mean of the beat rates is the wrong session average, and compare with the strap's own smoothed display.

  1. 1Gather (used)
  2. 2Statistics (used)
  3. 3Visualize (used)
  4. 4Cleanse
  5. 5Features (used)
  6. 6Balance
  7. 7Scale
  8. 8Split
  9. 9Deploy
  1. Ask
  2. Collect (this week)
  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-13 Find the beats in ten seconds of ECG.

The decision

An athlete asks for the average and the peak heart rate of a short session. Which number from the strap answers each, and how should the average be computed?

The raw data

Try it

A chest strap reports two things: the time between beats (the RR interval, in milliseconds) and a heart rate for its display. They are not the same number. This file is eight minutes of the instructor wearing a Polar H10: quiet at first, then two short efforts, then rest. Every ECG sample is a row; the rr column is filled on the rows where the strap reported a beat interval, and the hr column on the rows where it reported its displayed heart rate.

Separate the beats from the display

PythonTwo outputs of one strap

Type a prediction to enable Run.

Show the expected result without running
65189 rows over 500.7 s (8.3 min)
673 beat intervals, 500 displayed heart rates
RR from 421 to 1436 ms; intervals add up to 499.9 s

The intervals add up to within a second of the recording's length, as they should if no beat is missing. A missed beat would leave a gap of a whole interval.

Heart rate, beat by beat

One beat that lasts RR milliseconds is a heart rate of 60 000 / RR beats a minute. That gives a heart rate for every beat. Now average it over the session, two ways.

PythonA rate per beat, and two averages

Type a prediction to enable Run.

Show the expected result without running
mean of the beat heart rates   90.1 beats/min
60 000 / mean RR               80.8 beats/min
beats / minutes                80.8 beats/min
strap's displayed mean         81.1 beats/min

They differ by about 9 beats a minute. A fast beat is short, so a minute of hard work holds many more beats than a minute of rest, and averaging over beats lets the hard minutes count too often. The heart rate of a session is beats divided by minutes, which is 60 000 divided by the mean interval. The strap's display agrees with that one.

Beat by beat against the display

PythonThe two outputs over time, and the peak

Type a prediction to enable Run.

Show the expected result without running
highest single beat 142.5 at 4.0 min
highest 5-second rate 133.4; highest displayed 134 beats/min
Heart rate in beats per minute against time in minutes. Dots, one per beat from the RR intervals, follow two efforts up to about 134; a few dots sit far from their neighbours, the highest at 142 near minute 4. The strap's displayed heart rate, a line, follows the dots smoothly.

The highest single beat, 142.5 beats a minute, sits alone, about 30 above the beats on either side of it. A heart does not jump that far for one beat during steady effort: a beat was mistimed, or a noise spike was counted. A few more such dots sit near minute 5.8. Averaged over five seconds, the peak is 133.4, and the strap's smoothed display, 134, agrees. Use the intervals for anything that changes within seconds, but never report one beat as a peak. Chapter 5 shows the rules that remove such beats; Q-15 uses one.

For the athlete: "Your heart rate over this session averaged about 81 beats a minute, and your peak was about 134; one beat that read 142 was a glitch, not you."

Action card

Action card
Finding
The session's heart rate was 80.8 beats a minute and its peak about 134.
Evidence
Beats divided by minutes and 60 000 over the mean interval agree; the mean of the beat rates (90.1) overcounts the fast beats. The 5-second peak (133.4) agrees with the display (134).
How sure
High; the intervals add up to within a second of the recording's length, so no beats are missing.
Action
Report session averages as beats per minute of time, and peaks as a short average, never a single beat.
Test again
Check the interval total against the recording length on every new file.

With your own data

Record a few minutes of rest and a short effort with the Heart app (or any logger that writes the same columns), open your file in place of this one, and check that your intervals add up to the recording length before you trust any average.

Check yourself

  1. Why is the mean of the beat-by-beat heart rates higher than the session's heart rate?

  2. An RR interval of 750 ms is what heart rate, in beats a minute?

    beats/min

  3. The highest single-beat heart rate is 142.5 but the highest 5-second rate is 133.4. Which is the peak to report?

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.