Course / Tutorials / Week 9 / Q-26
Quick tutorial Q-26 · Week 9 · about 15 min · Foundation
Cadence from a cycle length
Get a runner's cadence three ways from one ankle trace, and see why a median step at 30 frames per second can only give 164 or 180.
- Ask
- Collect
- Check
- Interpret (this week)
- Coach
- Reassess
Download notebook ·Python file ·Read as Markdown ·Data folder ·Chapter 9 (sections 9.1, 9.2, 9.8)
Every cell runs in this page; the first run downloads Python (about 30 s). Nothing you load leaves your browser. Helpful first: Q-25 Find foot contacts in an ankle trace.
The decision
A runner's cadence is the first number a coach asks for. From a 30-frames-per-second clip, which way of computing it gives a number good to a step or two a minute?
The raw data
raw/form1_ankles.csv: both ankles' image position and confidence in every frame of a treadmill run filmed from behind at 30 frames per second (464 rows). Chapter 9's example table, also published with the book's data (book/ch09-gait).
Try it
Cadence is steps per minute. A stride is one foot's contact to that foot's next contact, and holds two steps, so
cadence = 60 / step time = 120 / stride time.
The ankle table is Chapter 9's treadmill runner, filmed from behind at 30 frames per second. Three ways to get the cycle length give three cadences. Find out why, and which to report.
Show the expected result without running
stride 21 frames = 0.700 s -> cadence 171.4 steps/min
Way 2 and Way 3 · From the contacts
Find each foot's contacts, at most one per 0.6 of a stride, merge the two feet into one list of steps, and take either the median step or the span: the number of steps divided by the time from the first contact to the last.
Type a prediction to enable Run.
Show the expected result without running
44 contacts, 43 steps; step lengths in frames: {8: 2, 9: 3, 10: 14, 11: 16, 12: 6, 13: 2}
median step 0.367 s -> 163.6 steps/min
span: 43 steps in 15.23 s -> 169.4 steps/min
line through all contacts: 0.3535 s per step -> 169.7 steps/minShow the expected result without running

At 30 frames per second a step can only be read as a whole number of frames: 10 frames gives 180 steps a minute, 11 frames gives 163.6, and nothing in between. Most of this runner's steps (30 of 43) are 10 or 11 frames, so the median lands on one of them, 163.6 here, and the autocorrelation's stride of 21 frames lands on 171.4. The span uses every step at once, so the rounding at its two ends is shared by 43 steps: 169.4 steps a minute, and a straight line through all the contact times agrees with it (169.7). The key idea from Chapter 9: a median of rounded intervals is still rounded; estimate a rate from many events at once.
For the athlete: your cadence from this clip is about 169 steps a minute; read it from the whole run, not from one or two steps.
With your own data
Run Q-25 and this page on your own two-ankle table, then count your steps over 30 s of the same clip by hand, double the count, and compare.
Check yourself
A stride takes 0.70 s. What is the cadence in steps per minute?
Why does the span of 43 steps give a better cadence than the median step?
The same method in another field
Any rate measured from events on a sampled clock, from shaft revolutions on a tachometer to heartbeats in a 250 Hz ECG, has the same choice: rate from the span of many events, not from the median of single intervals.
Acknowledgements
Ankle table from Chapter 9 of Data-Driven Athletics.
References
- Chapter 9 of Data-Driven Athletics: Period first, then events; The frame budget.
Built 2026-11-30 with Python packages numpy 2.5.5, pandas 3.1.1, matplotlib 3.11.2, scipy 1.18.1. In the browser the same code runs on Pyodide, so the last digit can differ.