Skip to content

Glossary

Harmonic mean

The right mean for averaging rates

By Published Updated

The harmonic mean of n values is n / (1/x₁ + 1/x₂ + ... + 1/xₙ) — the reciprocal of the arithmetic mean of the reciprocals. It’s the right average when averaging rates expressed as ratio-units (miles per hour, requests per second, dollars per item).

Canonical example. Drive 60 miles at 30 mph, then 60 miles at 60 mph. What’s the average speed?

  • Arithmetic mean: (30 + 60) / 2 = 45 mph. Wrong.
  • Harmonic mean: 2 / (1/30 + 1/60) = 40 mph. Correct.

Sanity check: total 120 miles, total time = 60/30 + 60/60 = 2 + 1 = 3 hours. 120 / 3 = 40 mph. The harmonic mean nails it; the arithmetic mean systematically over-weights the higher rate.

The harmonic mean is always ≤ geometric mean ≤ arithmetic mean. The chain HM ≤ GM ≤ AM is one of the classical inequalities in mathematics. Choosing the wrong one is the silent cause of many real-world arithmetic errors — averaged fuel-economy figures, computed network throughput, mean-time-to-failure for parallel systems.

Use harmonic mean whenever the natural “average” is a rate over a constant numerator (constant distance, constant work to be done). Use arithmetic mean for additive quantities (heights, scores). Use geometric mean for multiplicative quantities (compound returns).

The F1 score in machine learning: the harmonic mean shows up everywhere in classification metrics because precision and recall live on competing scales. The F1 score = 2 × precision × recall / (precision + recall) is exactly the harmonic mean of precision and recall — penalising imbalance more harshly than the arithmetic mean would. A classifier with 95% precision and 10% recall has arithmetic mean 52.5% but F1 score 18.1%. The harmonic mean correctly says “this is a bad model” while the arithmetic mean suggests a coin-flip. Every modern ML evaluation framework defaults to F-scores for this reason. Reference: NIST/SEMATECH e-Handbook — Harmonic mean.

Parallel resistors and the harmonic mean. The total resistance of n resistors in parallel is 1 / (1/R₁ + ... + 1/Rₙ), which is the harmonic mean of the resistances divided by n. Two 100 Ω resistors in parallel give 50 Ω, which is the harmonic mean of (100, 100) divided by 2. The same identity drives parallel pipes carrying fluid, parallel processors splitting a workload, and parallel database connections under a connection-pool ceiling — anything where the limiting quantity is reciprocal-additive rather than additive. Recognising the harmonic mean in these contexts saves you from re-deriving the formula every time.

Why the harmonic mean is sensitive to small values. Because each term contributes via its reciprocal, a single value near zero pulls the entire mean towards zero. A dataset of (1, 1, 1, 1, 0.01) has arithmetic mean 0.802 but harmonic mean 0.0476 — the single small value dominates. This is a feature, not a bug: when averaging rates, a slow leg of the trip should drag the overall average down because you spend a disproportionate amount of time at that slow rate. The same property makes harmonic mean unsuitable for data that legitimately contains near-zero values (and undefined when any value is exactly zero, because 1/0 is undefined).

Computing the harmonic mean without losing precision. The naive formula n / sum(1/x) compounds rounding errors when the values span many orders of magnitude. A more numerically stable approach is to compute the reciprocals in higher precision, sort them by magnitude, sum smallest-to-largest, then take the reciprocal. For most everyday datasets the naive form is fine; for financial calculations spanning fractions of a basis point alongside whole-number multiples, the sorted variant gives 2–3 extra digits of accuracy. Convertitive’s statistics calculator uses double precision throughout, which is accurate enough for any dataset where each value fits in a JavaScript Number.

Frequently asked questions

What is the harmonic mean?
The harmonic mean of n values is n divided by the sum of their reciprocals. It is the correct average for rates where the denominator — distance, volume, time — varies across observations.
When should I use the harmonic mean?
Use it when averaging rates over a fixed amount of the numerator: average speed over equal distances, average MPG over equal miles driven, or average P/E ratio over equal capital invested.
What is the difference between harmonic mean and arithmetic mean for speeds?
If you drive 60 mph for 100 miles and 30 mph for 100 miles, the arithmetic mean (45 mph) is wrong; the harmonic mean (40 mph) correctly reflects the time-weighted trip average.
Can the harmonic mean handle zero or negative values?
No — a zero in the data set makes the harmonic mean undefined (division by zero in the reciprocal sum), and negative values produce counterintuitive results. It is only valid for strictly positive quantities.

Related

Published May 16, 2026 · Last reviewed May 31, 2026