Harmonic Mean Calculator (with Weighted Harmonic Mean)
Find the harmonic mean of positive numbers, or the weighted harmonic mean with your own weights, with the sum of reciprocals, a step-by-step table and the geometric and arithmetic means for comparison.
How it works
HM = n ÷ Σ(1 ÷ xᵢ) · Weighted HM = Σwᵢ ÷ Σ(wᵢ ÷ xᵢ) · Two values: HM = 2ab ÷ (a + b)
The harmonic mean divides the number of values by the sum of their reciprocals. It is the reciprocal of the average of the reciprocals, which makes it the correct average for rates measured against a fixed amount of something: speeds over equal distances, prices when you spend the same amount each time (dollar-cost averaging), price-to-earnings ratios in an index, or the F1 score that combines precision and recall. When the parts are not equal, use the weighted harmonic mean, Σw ÷ Σ(w ÷ x), with the weights in the numerator unit of the rate: for average speed over legs of different length, the weights are the distances. Because it is pulled toward small values, the harmonic mean is always the smallest of the three Pythagorean means (harmonic ≤ geometric ≤ arithmetic), with equality only when all values are the same. It needs strictly positive values, since a zero would make a reciprocal infinite.
Worked example
For the default values 1, 2 and 4 the reciprocals are 1, 0.5 and 0.25, which sum to 1.75. The harmonic mean is 3 ÷ 1.75 = 1.714286. The geometric mean is ∛(1 × 2 × 4) = 2 and the arithmetic mean is 7 ÷ 3 = 2.333333, so the harmonic mean is the lowest, as it always is.
Sources: Harmonic mean — Wikipedia · Omni Calculator: Harmonic mean (formulas and examples) · GigaCalculator: Harmonic mean, weighted P/E and speed examples
Frequently asked questions
When is the harmonic mean the right average?
Use it for rates where the amount in the numerator is fixed. Driving 120 km at 80 km/h and returning 120 km at 60 km/h averages 2 × 120 ÷ (1.5 h + 2 h) = 68.57 km/h, which is the harmonic mean of 80 and 60, not their arithmetic mean of 70.
How do I calculate a weighted harmonic mean?
Divide the sum of the weights by the sum of each weight divided by its value: Σw ÷ Σ(w ÷ x). For an index with P/E ratios 10, 9 and 50 and weights 0.60, 0.25 and 0.15, the result is 1 ÷ (0.06 + 0.02778 + 0.003) = 11.02, much lower than the weighted arithmetic mean of 15.75.
What is the formula for the harmonic mean of two numbers?
For two numbers a and b it simplifies to 2ab ÷ (a + b). For 2 and 8 that is 32 ÷ 10 = 3.2. It also equals the geometric mean squared divided by the arithmetic mean: 4² ÷ 5 = 3.2.
How does it relate to the geometric and arithmetic means?
For positive numbers, harmonic ≤ geometric ≤ arithmetic, with equality only when every value is the same. The more spread out the data, the larger the gaps between the three.
Why must the values be positive?
The formula adds reciprocals. A zero has no reciprocal, and negative values can make the sum of reciprocals zero or change its sign, so the harmonic mean is defined only for strictly positive numbers.
Related calculators
For education: check that the harmonic mean suits your data (rates with a fixed numerator) before using it in a report or decision.