1) Definition

  • The harmonic mean of $n$ positive numbers $x_1, x_2, …, x_n$​ is:

$H = \frac{n}{\frac{1}{x_1} + \frac{1}{x_2} + \dots + \frac{1}{x_n}}$

It is the reciprocal of the arithmetic mean of reciprocals.


2) Comparison with Other Means

For two numbers $a$ and $b$:

  • Arithmetic mean (AM): $\frac{a+b}{2}$​
  • Geometric mean (GM): $\sqrt{ab}$​
  • Harmonic mean (HM): $\frac{2}{\frac{1}{a} + \frac{1}{b}} = \frac{2ab}{a+b}$

Relationship: $\text{HM} \leq \text{GM} \leq \text{AM}$


3) Why it is useful

  • Balances ratios: Harmonic mean is appropriate when numbers are rates or ratios (like speed, precision/recall).
  • It gives more weight to smaller values.
    • Example: If one number is very small, HM will also be small.
    • Prevents one large number from dominating the average.

4) Example: Average Speed

Suppose you drive:

  • 60 km at 60 km/h, then 60 km at 120 km/h.
  • Arithmetic mean speed = (60 + 120) / 2 = 90 km/h (wrong).
  • True average speed:
    • Time1 = 60/60 = 1h
    • Time2 = 60/120 = 0.5h
    • Total distance = 120 km
    • Total time = 1.5h
    • Avg speed = 120/1.5 = 80 km/h

Now check with Harmonic mean: $H = \frac{2}{\frac{1}{60} + \frac{1}{120}} = 80$

Correct.


5) Example in Machine Learning: F1-score

  • F1 = harmonic mean of precision and recall:

$F1 = \frac{2}{\frac{1}{\text{Precision}} + \frac{1}{\text{Recall}}}$

If either precision or recall is very low, F1 becomes low (balanced measure).


6) Summary

  • Harmonic mean = reciprocal of arithmetic mean of reciprocals.
  • Best for rates or when smaller values should dominate.
  • Ensures balance (one very low value pulls mean down strongly).