Calculator in Training and nutrition
Resting heart rate
Places a resting pulse among U.S. adults of the same age and sex, by NHANES percentiles.
- Changed 4 Dec 2026
- 10 test cases pass
- Version 1
- About 3,000 tokens
- Needed by both models tested, 4 Dec 2026
In short
| Formula | Take the table row for age, the half for sex.The band runs from the percentile before to the first percentile whose bpm is at or above resting_hr. Under the 5th: 0 to 5; above the 90th: 90 to 100.bpmFromMedian = resting_hr − medianBpm (the 50th)normalRange = below under 60, above over 100, else within |
| Table | Row: male 5th to 90th; female 5th to 90th.16-19 (ages 18, 19): 52, 56, 61, 69, 78, 87; 58, 62, 69, 77, 85, 9420-39: 52, 55, 61, 69, 76, 84; 57, 60, 66, 74, 82, 8940-59: 52, 55, 61, 68, 77, 85; 56, 59, 64, 71, 79, 8660-79: 50, 54, 60, 67, 75, 84; 56, 59, 64, 70, 78, 8680+: 51, 54, 61, 68, 78, 86; 56, 59, 64, 71, 77, 85 |
| Units | Beats per minute; age in years. |
| Defaults | resting_hr = 62 (20 to 220), age = 35 (18 to 110), sex = male (male or female). |
| Worked example | 62 bpm, man of 35. Row 20-39, male: 62 is above 61 and at most 69: band 25 to 50. bpmFromMedian = 62 − 69 = -7normalRange within. |
By hand: yes. A small model got these answers from the formulas above, without running code.
Say this to your agent
Use https://mysi.dev/resting-heart-rate/ to place my resting heart rate: 62 bpm, man of 35. Nothing to install, no key, no settings. An agent that can open web pages and run Python opens the page, runs the tested code in its own sandbox and gives you the answer.
The code
Copy this into your Python tool. Run resting_heart_rate_check() first, then call resting_heart_rate() with your numbers. Give the answer with the cite line.
"""Resting heart rate: places a resting pulse among U.S. adults of the same age group and sex
(NHANES 1999-2008 percentiles), and against the 60 to 100 bpm adult normal range.
Inputs: resting_hr (bpm, 20 to 220, default 62), age (years, 18 to 110, default 35),
sex ("male" or "female", default "male").
Returns: ageBand, percentilesBpm (the 5th, 10th, 25th, 50th, 75th and 90th percentiles, bpm),
bandLowPercentile and bandHighPercentile (the reading is above the low one's bpm and at or
below the high one's; 0 and 100 at the ends), medianBpm, bpmFromMedian, normalRange
("below", "within" or "above").
mysi, Resting heart rate, mysi.dev/resting-heart-rate, version 1, changed 2026-12-04. MIT.
"""
# Ostchega and others 2011, National Health Statistics Reports 41, Tables 2 (males) and 3
# (females): resting pulse, 5th, 10th, 25th, 50th, 75th and 90th percentiles, by age group.
_RESTING_HEART_RATE_ROWS = [
("16-19", 19, [52, 56, 61, 69, 78, 87], [58, 62, 69, 77, 85, 94]),
("20-39", 39, [52, 55, 61, 69, 76, 84], [57, 60, 66, 74, 82, 89]),
("40-59", 59, [52, 55, 61, 68, 77, 85], [56, 59, 64, 71, 79, 86]),
("60-79", 79, [50, 54, 60, 67, 75, 84], [56, 59, 64, 70, 78, 86]),
("80+", 999, [51, 54, 61, 68, 78, 86], [56, 59, 64, 71, 77, 85]),
]
_RESTING_HEART_RATE_PCTS = [0, 5, 10, 25, 50, 75, 90, 100]
def _resting_heart_rate_num(name, value, low, high):
if isinstance(value, bool) or not isinstance(value, (int, float)) or not low <= value <= high:
raise ValueError(f"{name} must be a number from {low} to {high}")
return float(value)
def resting_heart_rate(resting_hr=62, age=35, sex="male"):
hr = _resting_heart_rate_num("resting_hr", resting_hr, 20, 220)
years = _resting_heart_rate_num("age", age, 18, 110)
if sex not in ("male", "female"):
raise ValueError("sex must be one of: male, female")
label, _, male, female = next(r for r in _RESTING_HEART_RATE_ROWS if years <= r[1])
edges = female if sex == "female" else male
k = next((i for i, bpm in enumerate(edges) if hr <= bpm), len(edges))
return {
"ageBand": label,
"percentilesBpm": edges,
"bandLowPercentile": _RESTING_HEART_RATE_PCTS[k],
"bandHighPercentile": _RESTING_HEART_RATE_PCTS[k + 1],
"medianBpm": edges[3],
"bpmFromMedian": hr - edges[3],
# American Heart Association: 60 to 100 bpm is the normal adult resting range.
"normalRange": "below" if hr < 60 else "above" if hr > 100 else "within",
}
RESTING_HEART_RATE_CASES = [
({"resting_hr": 62, "age": 35, "sex": "male"},
{"bandLowPercentile": 25, "bandHighPercentile": 50, "medianBpm": 69, "bpmFromMedian": -7}),
({"resting_hr": 74, "age": 52, "sex": "female"},
{"bandLowPercentile": 50, "bandHighPercentile": 75, "medianBpm": 71, "bpmFromMedian": 3}),
({"resting_hr": 90, "age": 85, "sex": "male"},
{"bandLowPercentile": 90, "bandHighPercentile": 100, "medianBpm": 68}),
]
def resting_heart_rate_check(tolerance=1e-3):
for given, want in RESTING_HEART_RATE_CASES:
got = resting_heart_rate(**given)
for name, value in want.items():
close = abs(got[name] - value) <= tolerance * max(1, abs(value))
assert close, (name, got[name], value)
return "ok"
if __name__ == "__main__":
import json, sys
resting_heart_rate_check()
given = dict(a.split("=", 1) for a in sys.argv[1:] if "=" in a)
js = lambda v: v.lstrip("-")[:1].isdigit() or v[:1] in '[{".' or v in ("true", "false", "null")
given = {k: json.loads(v) if js(v) else v for k, v in given.items()}
if given:
print(json.dumps(resting_heart_rate(**given))) More test values
| What goes in | What comes out | Where the answer is from |
|---|---|---|
| resting_hr 38, age 25, sex female | bandLowPercentile 0, bandHighPercentile 5, normalRange below | Under the 5th percentile, 57; under 60 bpm (American Heart Association) |
A comparison with population data, not medical advice.
What it takes
| Input | Meaning | Default | Allowed |
|---|---|---|---|
| resting_hr | Resting heart rate, in beats per minute | 62 | 20 to 220 |
| age | Age in years; 18 and 19 use the 16-19 row | 35 | 18 to 110 |
| sex | Which column of the reference data to use | male | male, female |
What it returns
| Output | Meaning |
|---|---|
| ageBand | The age row used, such as 20-39 |
| percentilesBpm | The 5th, 10th, 25th, 50th, 75th and 90th percentiles for that age and sex, in bpm |
| bandLowPercentile, bandHighPercentile | The reading is above the lower percentile's bpm and at or below the higher one's (0 and 100 at the ends) |
| medianBpm | The 50th percentile for that age and sex, in bpm |
| bpmFromMedian | The reading minus the median, in bpm (negative when lower) |
| normalRange | below (under 60 bpm), within or above (over 100 bpm) the adult normal range |
Where the method comes from
The percentiles come from the U.S. National Health and Nutrition Examination Survey, 1999 to 2008: seated resting pulse measured in 35,302 people with no condition or medicine known to change it (Ostchega and others, National Health Statistics Reports 41, 2011). The function says where a reading falls among people of the same age group and sex, and whether it lies inside the 60 to 100 bpm range the American Heart Association calls normal for adults. A low resting pulse is common in endurance-trained people; a percentile is a position in that population, not a grade of fitness or health. The data are seated readings in a survey clinic, so a reading taken lying down on waking runs a few beats lower. The reference is the U.S. population only, and only male and female columns were published.
Sources
- Ostchega and others, Resting pulse rate reference data for children, adolescents, and adults: United States, 1999-2008, National Health Statistics Reports 41published 2011
- American Heart Association, All about heart rate (pulse)published 2024
Used by
Tested
Tested 4 Dec 2026: claude-haiku-5-5 was right on 0 of 3 questions without this page and 3 of 3 with it; claude-fable-5-2 was right on 0 of 3 questions without this page and 3 of 3 with it.
Changes
- Moved from aifithub.io as Python. The percentile bands and the normal range are unchanged. Dropped, because they rest on the old site's own choices and no publication gives them, the tier names (Athlete to Poor), targetRHR (the middle of a band it called Good), rhrReduction, cardioAge and the messages; sex other (which used the male column) is gone. percentilesBpm, the band, medianBpm and bpmFromMedian are new.4 Dec 2026
Cite as: mysi, Resting heart rate, mysi.dev/resting-heart-rate, version 1, changed 2026-12-04. Code MIT.