Foundations · Averages
Harmonic Mean Calculator
The harmonic mean is the average for rates — speeds, prices per unit, things measured as “per” something — where the arithmetic mean overcounts. Drive somewhere at 60 and back at 30 and your average speed is 40, not 45, because you spend twice as long on the slow leg. This computes the harmonic mean of any positive values, or the true average speed across equal-distance legs, and shows it against the other means.
Harmonic mean = n ∕ Σ(1∕xᵢ): the reciprocal of the average of the reciprocals. Use it for rates and ratios; all values must be greater than zero.
Each speed covers the same distance. The average speed for the whole trip is the harmonic mean of the leg speeds — not their arithmetic average, because slower legs take more time.
Result
In plain English
When you average a rate, what you really want to hold fixed is the thing the rate is measured against — the distance, not the time; the dollars, not the shares. The arithmetic mean of the rates quietly assumes you spend equal time at each, when in fact you spend equal distance, and the slow rate eats up more time. The harmonic mean corrects for that by averaging in reciprocal space, which is why it always comes out at or below the arithmetic mean.
- harmonic mean
- n divided by the sum of the reciprocals: n ∕ (1∕x₁ + 1∕x₂ + … + 1∕xₙ). Equivalently, take the reciprocal of each value, average those, and flip back.
- why it suits rates
- For a rate like speed (distance ∕ time), the honest average over equal distances is total distance ∕ total time — and that works out to be exactly the harmonic mean of the speeds.
- HM ≤ GM ≤ AM
- For any positive numbers the harmonic mean is the smallest of the three classical means, the arithmetic the largest, with the geometric between them; they are equal only when every value is the same.
- the slow leg dominates
- Halving your speed doubles the time that stretch takes, so a slow segment counts for more in the average than a fast one. The harmonic mean is dragged toward the smaller values.
- the F-score
- The F₁ score in machine learning is the harmonic mean of precision and recall — chosen precisely because it punishes a model that is lopsided, refusing to let a high score on one paper over a low score on the other.
- when not to use it
- If the quantity you hold fixed is time rather than distance (you drive 60 for an hour, then 30 for an hour), the arithmetic mean is right. Always ask: equal amounts of what?
Frequently asked
How do you calculate the harmonic mean?
Take the reciprocal of each value, average those reciprocals, and take the reciprocal of the result: HM = n ∕ (1∕x₁ + … + 1∕xₙ). For 2, 3 and 6 that is 3 ∕ (1∕2 + 1∕3 + 1∕6) = 3 ∕ 1 = 3. Every value must be positive, since a zero makes a reciprocal blow up. The harmonic mean is always the smallest of the three classical means for a given set of positive numbers.
Why is the average of 60 mph and 30 mph equal to 40, not 45?
Because you spend more time at the slower speed. Over equal distances — say 60 miles each way — the outward leg at 60 mph takes 1 hour and the return at 30 mph takes 2 hours, so you cover 120 miles in 3 hours: an average of 40 mph. The arithmetic average, 45, would only be right if you spent equal time at each speed, not equal distance. The harmonic mean, 2 ∕ (1∕60 + 1∕30) = 40, builds in the fact that slow legs take longer.
When should I use the harmonic mean instead of the arithmetic mean?
Use it when averaging rates or ratios where the numerator of the rate is held constant — average speed over equal distances, average price-to-earnings across an index, average cost per unit for a fixed budget, the F₁ score. The giveaway is a quantity expressed as “X per Y” where you are accumulating equal amounts of X. If instead you hold Y constant (equal time, equal weighting), use the arithmetic mean. Getting this wrong always inflates the average.
What is the relationship between the harmonic, geometric and arithmetic means?
For any set of positive numbers they obey HM ≤ GM ≤ AM, with all three equal only when every value is identical. The more the values are spread out, the wider the gaps. Each suits a different kind of quantity: arithmetic for things that add, geometric for things that multiply (growth, ratios), harmonic for rates. They are linked too — the geometric mean is the geometric mean of the other two, and for two numbers GM² = AM × HM.