The harmonic mean is the average built for rates, ratios, and speeds — situations where the arithmetic mean quietly gives you the wrong answer. It shows up anywhere a quantity is expressed "per unit" of something else, from average driving speed to the F1 score used to evaluate machine-learning models.

How the harmonic mean works

The harmonic mean is computed by taking the reciprocal of every value, averaging those reciprocals, and then taking the reciprocal of that average: HM = n / Σ(1/xᵢ). Because it operates on reciprocals, a single small value pulls the harmonic mean down disproportionately — which is precisely the behavior you want when averaging rates, since a slow leg of a journey or a low precision score should dominate the average, not get washed out by a fast or high value elsewhere in the set.

Average speed: why the harmonic mean gets it right

If you drive 40 mph for one leg of a trip and 60 mph for an equal-distance return leg, your average speed for the whole trip is 48 mph — not the arithmetic average of 50 mph. That's because you spend more time traveling at the slower speed than the faster one, and average speed is really total distance divided by total time, not an average of the two numbers themselves. The harmonic mean of the leg speeds gives exactly this figure, as long as every leg covers the same distance. If your legs cover different distances, the plain harmonic mean is no longer correct — you'd need to weight each speed by the distance or time it actually covers.

Harmonic mean vs. arithmetic and geometric mean

All three are "Pythagorean means," but they answer different questions. The arithmetic mean sums values and divides by the count — the right choice for plain totals. The geometric mean multiplies values and takes the nth root — the right choice for growth rates and ratios that compound over time. The harmonic mean sums reciprocals — the right choice for rates and speeds. For any set of positive numbers that aren't all identical, HM ≤ GM ≤ AM always holds, with the gap between them widening as the values spread further apart.