MathsAverages & Ratios

Harmonic Mean
calculator.

The harmonic mean is the fair average of rates such as speeds, prices and fuel use.

How it's worked out

Take the reciprocal of each value, which means 1 divided by it. Average those, then flip the result back. NIST writes it as the count of values over the sum of the reciprocals.

H\displaystyle H=n1x1+1x2+⋯+1xn\displaystyle {}= \frac{n}{\frac{1}{x_1} + \frac{1}{x_2} + \cdots + \frac{1}{x_n}}

Here n is how many values you have, and each x is a value above 0. Small values have large reciprocals, so they count for more. That is what happens on a road: you spend longer at the slow speed, so the slow speed has more say in the result.

When the amounts differ, give each rate a weight equal to its amount of the top quantity. For a trip, the rate is km per hour and the top quantity is km, so the weight is the length of the leg.

Hw\displaystyle H_w=w1+w2+⋯+wnw1x1+w2x2+⋯+wnxn\displaystyle {}= \frac{w_1 + w_2 + \cdots + w_n}{\frac{w_1}{x_1} + \frac{w_2}{x_2} + \cdots + \frac{w_n}{x_n}}

Each w over x is the time spent on one leg, so this is total distance over total time. Take 120 km at 60 km/h and 60 km at 30 km/h. That is 180 km in 4 hours, or 45 km/h. The plain average of the two speeds is also 45 here, but only by chance: each leg happens to take 2 hours.

Worked examples

Maya drives out at 60 km/h and back at 40 km/h

Maya drives to a town and back on the same road, so each speed covers the same distance. The harmonic mean is 48 km/h, not 50.

Test it with a 120 km road. The way out takes 2 hours and the way back takes 3, so she covers 240 km in 5 hours, which is 48 km/h. The slow leg takes 60% of the time, which is why the answer sits nearer 40.

She wanted to average 50 km/h. With 60 on the way out, she needed 42.86 km/h on the way back, not 40. A 10% rise in her slow speed lifts the result to 50.77, while a 10% rise in her fast speed lifts it only to 49.81.

Open this example in the tool

Reading a car rated 25 mpg city and 36 mpg highway

US rules set combined fuel economy by harmonically averaging the city and highway figures, weighted 0.55 and 0.45. Miles per gallon is a rate, and the top quantity is miles, so these weights say 55 of every 100 miles are city miles.

Enter 25 with a weight of 55 and 36 with a weight of 45. Those 100 miles burn 3.45 gallons, and the result is 28.99 mpg. The weighted plain average would say 29.95 mpg, which is too high.

City driving takes 64% of the fuel here, more than its 55% of the miles. As an exact fraction the answer is 2,000 over 69.

Open this example in the tool

Putting $1,000 into each of three stocks

Three stocks have price to earnings ratios of 15, 25 and 10. With $1,000 in each, the money buys $66.67, $40.00 and $100.00 of yearly earnings. Each dollar buys earnings at the rate of 1 over the ratio.

So $3,000 buys $206.67 of earnings, and the group has a ratio of 14.52. The plain average of 16.67 overstates it, because the costly stock adds little in earnings for its dollars.

This only holds for equal dollars in each stock. With unequal amounts, enter the dollars as weights.

Open this example in the tool

Reading your result

Ask what stays the same. Use this mean when each rate goes with the same amount of the top quantity: the same distance at each speed, or the same dollars at each price. If the bottom quantity stays the same, use the arithmetic mean. An hour at 60 km/h and an hour at 40 km/h does average 50 km/h.

Expect it to be the lowest of the three common means. For positive numbers the harmonic mean is at most the geometric mean, and that is at most the arithmetic mean. They match only when every value is the same, and the gap grows as the values spread out.

The harmonic (H), geometric (G) and arithmetic (A) means for a few lists
ValuesHGA
60, 404848.9950
1, 4, 422.523
10, 20, 3016.36418.17120
5, 5, 5555
1, 1001.981050.5

Know where the top is. On a round trip you cannot pass twice the speed of the leg you have already driven, however fast you go on the other one. The target solver shows that limit. Maya's trip, with 60 km/h on the way out, can never reach 120 km/h.

Watch one small value. Run 1 and 100 and you get 1.98, close to the 1 and far from the 100. Check that a tiny entry is real and not a unit slip before you trust the answer.

Common mistakes

  • Using it with equal times. If you drive for one hour at each speed, the plain average is correct and this one is too low.
  • Weighting by the wrong amount. Weights must be the top quantity. For speed, that means distance, not time. If you only know the time at each speed, use the time as a weight in an ordinary weighted average instead.
  • Using it for growth. Yearly returns compound, so they call for the geometric mean, not this one. For an everyday list of scores or prices, use the average calculator.
  • Mixing units. Do not list 60 km/h next to 40 mph. Convert first, or the small figure takes too much of the result.

Questions people ask

You spend more time at the slow speed, so it counts for more. At 40 and 60 the fair figure is 48, not 50, since the slow leg takes 3 hours for every 2 on the fast leg. Any average of speeds has to come from total distance over total time.

Sources