Harmonic Mean Calculator
Calculate the harmonic mean (n ÷ sum of reciprocals) of any set of positive numbers. Perfect for averaging speeds, rates, and ratios.
Results
Harmonic Mean
The harmonic mean HM = n / Σ(1/xᵢ) — the count divided by the sum of the reciprocals of each value. It is always the smallest of the three Pythagorean means: HM ≤ GM ≤ AM (harmonic ≤ geometric ≤ arithmetic), with equality only when all values are identical.
Average Speed Example
If you drive 60 mph for 100 km, then 40 mph for the same 100 km, what is your average speed? Time at 60: 100/60 h. Time at 40: 100/40 h. Total time: 100/60 + 100/40 = 250/120 h. Total distance: 200 km. Average speed = 200 ÷ (250/120) = 96 km / (250/120 h) = 48 mph. This equals the harmonic mean: 2/(1/60 + 1/40) = 48 mph.
F1 Score
In machine learning, F1 = 2 × (Precision × Recall) / (Precision + Recall) — the harmonic mean of precision and recall. The harmonic mean penalizes extreme imbalance between the two: if one is 1.0 and the other 0.0, the harmonic mean is 0 (not 0.5 as the arithmetic mean would give).
Worked Example: Fuel Efficiency
A driver makes two equal-distance trips: one at 50 mph and one at 70 mph. The arithmetic mean of 50 and 70 is 60 mph. But the correct average speed over equal distances uses the harmonic mean:
HM = 2 / (1/50 + 1/70) = 2 / (0.02 + 0.01429) = 2 / 0.03429 ≈ 58.33 mph. The actual average is 58.33 mph, not 60 mph, because more time is spent at the slower speed.
AM, GM, HM Comparison
| Values | Arithmetic Mean | Geometric Mean | Harmonic Mean |
|---|---|---|---|
| 2, 8 | 5.00 | 4.00 | 3.20 |
| 10, 40 | 25.00 | 20.00 | 16.00 |
| 3, 3, 3 | 3.00 | 3.00 | 3.00 |
| 1, 10 | 5.50 | 3.16 | 1.82 |
Notice that AM ≥ GM ≥ HM for all positive values, with equality only when all values are the same. The greater the spread in values, the larger the difference between the three means.
Frequently Asked Questions
HM = n / (1/x₁ + 1/x₂ + … + 1/xₙ). For two values a and b: HM = 2ab/(a+b). For three values: HM = 3abc/(ab+bc+ca).
When you travel equal distances at different speeds, the harmonic mean gives the correct average speed. The arithmetic mean of speeds is correct only when you spend equal time at each speed, not equal distance.
AM ≥ GM ≥ HM always (the AM-GM-HM inequality). All three are equal when all values are the same. HM = GM²/AM for two positive numbers. These three means are called the Pythagorean means.
No. A zero value creates a zero reciprocal (1/0 → undefined) and makes the harmonic mean undefined. All inputs must be positive (> 0).
When averaging price-to-earnings (P/E) ratios across companies in a portfolio or index, the harmonic mean gives a more accurate result than the arithmetic mean. The harmonic mean of P/E ratios is equivalent to dividing the total market cap by the total earnings — which is how composite indices like the S&P 500 P/E is calculated. Arithmetic averaging of P/E ratios overweights companies with high P/E values.
When values differ greatly (e.g., 1 and 1000), the harmonic mean is dominated by the smaller values, while the arithmetic mean is dominated by the larger. For [1, 1000]: AM = 500.5, GM ≈ 31.6, HM ≈ 2.0. This is why the harmonic mean is appropriate when you are averaging rates — a very slow rate deserves more weight than a very fast one of equal importance.