What is Harmonic mean?

The reciprocal of the mean of reciprocals, used to average rates over equal amounts of work.

Field: Performance Analysis

Japanese name: 調和平均

Definition and calculation

The harmonic mean is obtained by taking the reciprocal of each value, averaging the reciprocals arithmetically and taking the reciprocal once more. For n values, n is divided by the sum of the reciprocals. The harmonic mean of 40 and 60 is 2 ÷ (1/40 + 1/60) = 48. It is smaller than the arithmetic mean of 50 and is pulled toward the smaller value. For positive values, the harmonic mean is no greater than the geometric mean, which is no greater than the arithmetic mean.

Why it is used to average rates

Suppose the same route is driven at 60 km/h on the way out and 40 km/h on the way back. If one way is 120 km, the outward trip takes 2 hours and the return takes 3 hours. The round trip of 240 km took 5 hours, so the overall average is 48 km/h. This equals the harmonic mean of the two speeds. The slower leg occupies more of the time, so the average leans toward the slower speed. In computing, the average of programs with the same instruction count run at different MIPS rates is found in the same way.

When it applies

The plain harmonic mean applies when the same amount of work is done at each rate. When the amounts differ, a harmonic mean weighted by the amount of work is used. If instead the same length of time is spent at each rate, the arithmetic mean is the correct average. Whichever mean is used, checking that it matches total work divided by total time guards against mistakes. To combine run times themselves, the arithmetic mean or the sum is used.

Try it: questions about Harmonic mean

Two programs with equal instruction counts run back to back, one at 1000 MIPS (1 billion instructions per second) and the other at 500 MIPS. What is the overall average rate?

  1. A750 MIPS
  2. BAbout 707 MIPS
  3. CAbout 667 MIPS
Show answer and explanation

Answer: C. About 667 MIPS

With I instructions each, the times are I1000I ÷ 1000 and I500I ÷ 500, totaling 3I10003I ÷ 1000. Executing 2I instructions in that time gives an average rate of2I3I1000≈6672I ÷ (3I ÷ 1000) ≈ 667MIPS. The slower program takes longer, pulling the average toward the slower rate. When averaging rates over equal amounts of work, use the harmonic mean, not the arithmetic mean.

FAQ

Why is the arithmetic mean of rates wrong?

Because it does not account correctly for the longer time taken by the slower work. Running the same number of instructions at 1000 MIPS and at 500 MIPS gives an average of about 667 MIPS, not 750 MIPS.

When does it differ greatly from the arithmetic mean?

When the values are spread widely. For 10 and 1000 the arithmetic mean is 505, but the harmonic mean is about 19.8. A single extremely slow piece of work strongly governs the overall average rate.

Books on Performance Analysis Ad

As an Amazon Associate I earn from qualifying purchases.

This page was drafted with AI and fact-checked by a separate AI review before publication. Our Editorial policy explains how we write and check content. If you spot an error, please tell us on our Contact page.

Back to the glossary