--- name: endurance-session-numbers description: Puts numbers on an endurance session from published equations and survey data - the flat-road equivalent pace of a treadmill run (ACSM running equation, Jones and Doust 1% rule), the energy of the run and of a walk (ACSM, 2024 Compendium METs), and where a resting heart rate sits among U.S. adults of the same age and sex (NHANES percentiles). Use it when someone gives a treadmill speed and incline, a walk, or a resting pulse and asks for pace, calories or percentile. --- # Numbers for an endurance session ## When to use - Someone ran or walked on a treadmill and asks for the outdoor (flat road) equivalent pace or the calories. - Someone asks the energy of a walk from body weight, speed band, minutes and slope. - Someone asks where a resting heart rate sits among adults of the same age and sex. - Not for training zones or race plans: those calculators are not on this page. ## Steps 1. Write down body weight in kg (pounds × 0.45359237), and for each part of the session its inputs: treadmill speed in km/h (mph × 1.609344), incline in percent, minutes, walking or running; walk speed band, slope and minutes; resting pulse, age and sex. 2. For a treadmill session call `treadmill_pace_converter(speed_kph, weight_kg, gait, incline_pct, duration_minutes)`. Set `gait="running"` for a run, `"walking"` for a walk on the belt. Set the incline even when it is 0; the default is 1. 3. From it take `outdoorEquivalentPaceMinPerKm` (flat road pace, minutes per km; per mile: `outdoorEquivalentPaceMinPerMile`) and `caloriesTotal` (kcal for the whole session). 4. For a walk call `walking_calorie(weight_kg, speed, duration_minutes, incline)`. `speed` is one of slow (2.0 mph), moderate (3.0), brisk (3.5), fast (4.0), very-fast (4.5); pick the band nearest the walker's speed and say which. `incline` is flat (0%), slight (2%), moderate (5%) or steep (10%). Take `calories` (gross) unless the user asks for energy above resting, then `netCalories`. 5. For the session's total energy, add `caloriesTotal` from step 3 and `calories` from step 4. 6. For a resting pulse call `resting_heart_rate(resting_hr, age, sex)`. Report the band as "between the `bandLowPercentile`th and `bandHighPercentile`th percentile" of its `ageBand`, and `bpmFromMedian`. 7. Report each figure with its unit, and pace as minutes and seconds per km (multiply the decimal part by 60). ## Mistakes this prevents - Treating the treadmill belt pace as the road pace, or applying the 1% rule backwards: on the road, the same effort as a 1% belt is the belt speed; at 0% belt incline the road pace is slower. - Leaving the incline out of the call: the function's default is 1%, not 0%. - Using the walking equation for a run or the running one for a walk; gait is an input, not guessed from speed. - Taking walking METs from memory or an older Compendium: the function carries the 2024 values. - Reading a pace like 5.714 min/km as 5:71; it is 5:43. - Calling a low percentile a health grade: it is a position among U.S. adults. ## Tell the user - Energy figures come from equations fitted to group averages; an individual can differ by 10 to 20% or more. - The outdoor-equivalent pace holds for running at about 10.5 to 18 km/h; for walking it is rough. - The heart-rate percentiles are U.S. NHANES 1999-2008 seated readings; a pulse taken lying down on waking runs a few beats lower. ## The code Copy each function into your Python tool. Run its check first. ### Treadmill pace converter (https://mysi.dev/treadmill-pace-converter/) ```python """Treadmill pace converter: belt pace, the flat pace of equal oxygen cost, the outdoor road equivalent, and calories, by the ACSM metabolic equations and the 1% rule of Jones and Doust. Inputs: speed_kph (1 to 30), incline_pct (0 to 30, default 1), weight_kg (1 to 300), gait (walking or running), duration_minutes (1 to 600, default 30). Returns: speedMph; paceMinPerKm, paceMinPerMile; adjustedSpeedKph, adjustedPaceMinPerKm, adjustedPaceMinPerMile; outdoorEquivalentSpeedKph, outdoorEquivalentPaceMinPerKm, outdoorEquivalentPaceMinPerMile; caloriesPerHour, caloriesTotal (kcal); distanceKm; raceTimesMinutes (5 km, 10 km, half and full marathon at the belt speed). mysi, Treadmill pace converter, mysi.dev/treadmill-pace-converter, version 1, changed 2026-12-04. MIT. """ def _treadmill_pace_converter_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 treadmill_pace_converter(speed_kph, weight_kg, gait, incline_pct=1, duration_minutes=30): num = _treadmill_pace_converter_num s = num("speed_kph", speed_kph, 1, 30) w = num("weight_kg", weight_kg, 1, 300) g = num("incline_pct", incline_pct, 0, 30) / 100 minutes = num("duration_minutes", duration_minutes, 1, 600) if gait not in ("walking", "running"): raise ValueError("gait must be one of: walking, running") mile = 1.609344 # km per international mile adjusted = s * (0.2 + 0.9 * g) / 0.2 # ACSM running equation, solved for 0% grade outdoor = s * (0.2 + 0.9 * (g - 0.01)) / 0.2 # 1% treadmill grade = flat road (Jones 1996) v = s * 1000 / 60 # metres per minute if gait == "walking": # ACSM walking and running equations, ml/kg/min vo2 = 0.1 * v + 1.8 * v * g + 3.5 else: vo2 = 0.2 * v + 0.9 * v * g + 3.5 per_hour = vo2 * w * 5 / 1000 * 60 # 5 kcal per litre of oxygen (ACSM) return { "speedMph": s / mile, "paceMinPerKm": 60 / s, "paceMinPerMile": 60 / s * mile, "adjustedSpeedKph": adjusted, "adjustedPaceMinPerKm": 60 / adjusted, "adjustedPaceMinPerMile": 60 / adjusted * mile, "outdoorEquivalentSpeedKph": outdoor, "outdoorEquivalentPaceMinPerKm": 60 / outdoor, "outdoorEquivalentPaceMinPerMile": 60 / outdoor * mile, "caloriesPerHour": per_hour, "caloriesTotal": per_hour * minutes / 60, "distanceKm": s * minutes / 60, # road race distances in km: 5 km, 10 km, half and full marathon (World Athletics) "raceTimesMinutes": [d / s * 60 for d in (5, 10, 21.0975, 42.195)], } TREADMILL_PACE_CONVERTER_CASES = [ ({"speed_kph": 10, "incline_pct": 2, "weight_kg": 70, "gait": "running", "duration_minutes": 30}, {"outdoorEquivalentSpeedKph": 10.45, "adjustedSpeedKph": 10.9, "caloriesTotal": 418.25}), ({"speed_kph": 6, "incline_pct": 12, "weight_kg": 80, "gait": "walking", "duration_minutes": 60}, {"paceMinPerKm": 10.0, "caloriesPerHour": 842.4, "distanceKm": 6.0}), ({"speed_kph": 15, "incline_pct": 0, "weight_kg": 60, "gait": "running", "duration_minutes": 20}, {"outdoorEquivalentPaceMinPerKm": 4.18848, "caloriesTotal": 321.0, "distanceKm": 5.0}), ] def treadmill_pace_converter_check(tolerance=1e-3): for given, want in TREADMILL_PACE_CONVERTER_CASES: got = treadmill_pace_converter(**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 treadmill_pace_converter_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(treadmill_pace_converter(**given))) ``` ### Walking calories (https://mysi.dev/walking-calorie/) ```python """Walking calories: energy burned on a walk from body weight, a speed band, the time and the slope. The level-walking MET comes from the 2024 Adult Compendium of Physical Activities; the slope adds the grade term of the ACSM walking equation. Inputs: weight_kg (1 to 300), speed (slow, moderate, brisk, fast, very-fast; default moderate), duration_minutes (1 to 600, default 30), incline (flat, slight, moderate, steep; default flat). Returns: calories and netCalories (kcal, 1 decimal), caloriesPerMinute (2 decimals), met (2 decimals), inclineMultiplier (3 decimals), durationHours (2 decimals). mysi, Walking calories, mysi.dev/walking-calorie, version 1, changed 2026-12-04. MIT. """ import math def _walking_calorie_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 _walking_calorie_pick(name, value, table): if not isinstance(value, str) or value not in table: raise ValueError(f"{name} must be one of: {', '.join(table)}") return table[value] def _walking_calorie_round(value, digits): return math.floor(value * 10 ** digits + 0.5) / 10 ** digits # half up, as the old engine def walking_calorie(weight_kg, speed="moderate", duration_minutes=30, incline="flat"): w = _walking_calorie_num("weight_kg", weight_kg, 1, 300) minutes = _walking_calorie_num("duration_minutes", duration_minutes, 1, 600) # speed band: (mph, level MET), 2024 Adult Compendium codes 17152, 17190, 17200, 17220, 17230 mph, level_met = _walking_calorie_pick("speed", speed, { "slow": (2.0, 2.8), "moderate": (3.0, 3.8), "brisk": (3.5, 4.8), "fast": (4.0, 5.5), "very-fast": (4.5, 7.0)}) grade = _walking_calorie_pick("incline", incline, { "flat": 0.0, "slight": 0.02, "moderate": 0.05, "steep": 0.10}) v = mph * 1609.344 / 60 # metres per minute met = level_met + 1.8 * v * grade / 3.5 # ACSM walking grade term, 3.5 ml/kg/min = 1 MET hours = minutes / 60 calories = met * w * hours # 1 MET = 1 kcal per kg per hour return { "calories": _walking_calorie_round(calories, 1), "netCalories": _walking_calorie_round((met - 1) * w * hours, 1), "caloriesPerMinute": _walking_calorie_round(calories / minutes, 2), "met": _walking_calorie_round(met, 2), "inclineMultiplier": _walking_calorie_round(met / level_met, 3), "durationHours": _walking_calorie_round(hours, 2), } WALKING_CALORIE_CASES = [ ({"weight_kg": 70, "speed": "brisk", "duration_minutes": 30, "incline": "slight"}, {"calories": 201.8, "netCalories": 166.8, "met": 5.77}), ({"weight_kg": 60, "speed": "moderate", "duration_minutes": 60, "incline": "flat"}, {"calories": 228.0, "netCalories": 168.0, "met": 3.8}), ({"weight_kg": 80, "speed": "slow", "duration_minutes": 45, "incline": "steep"}, {"calories": 333.5, "netCalories": 273.5, "met": 5.56}), ] def walking_calorie_check(tolerance=1e-3): for given, want in WALKING_CALORIE_CASES: got = walking_calorie(**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 walking_calorie_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(walking_calorie(**given))) ``` ### Resting heart rate (https://mysi.dev/resting-heart-rate/) ```python """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))) ``` Cite as: mysi, Numbers for an endurance session, mysi.dev/endurance-session-numbers, version 1, changed 2026-12-04. MIT.