Harmonic Mean Calculator

Calculate mean for rates and ratios.

Enter numbers separated by commas, spaces, or newlines

Examples:

Enter your data to see results

What Is the Harmonic Mean?

The harmonic mean is the reciprocal of the arithmetic mean of reciprocals:

HM=nβˆ‘i=1n1xi=n1x1+1x2+β‹―+1xnHM = \frac{n}{\sum_{i=1}^{n} \frac{1}{x_i}} = \frac{n}{\frac{1}{x_1} + \frac{1}{x_2} + \cdots + \frac{1}{x_n}}

Key property: The harmonic mean is appropriate when averaging rates, speeds, or ratios where the denominator varies.

When to Use Harmonic Mean

Averaging Speeds

Scenario: Drive 60 km at 30 km/h, then 60 km at 60 km/h. What's the average speed?

Wrong (arithmetic mean): (30 + 60) / 2 = 45 km/h

Correct (harmonic mean): HM=2130+160=2120=40 km/hHM = \frac{2}{\frac{1}{30} + \frac{1}{60}} = \frac{2}{\frac{1}{20}} = 40 \text{ km/h}

Verification:

  • Time for first leg: 60/30 = 2 hours
  • Time for second leg: 60/60 = 1 hour
  • Total: 120 km in 3 hours = 40 km/h βœ“

Price-to-Earnings Ratios

When averaging P/E ratios across stocks, harmonic mean weights by market cap implicitly.

StockP/E RatioEarnings
A10$100M
B20$100M

Arithmetic mean P/E: 15 Harmonic mean P/E: 2110+120=13.33\frac{2}{\frac{1}{10} + \frac{1}{20}} = 13.33

The harmonic mean correctly reflects the combined P/E of a portfolio.

Rates and Densities

When the numerator is fixed and denominators vary:

  • Machine processing rates (items per hour)
  • Fuel efficiency (miles per gallon for equal distances)
  • Population densities (for equal areas)

Calculation Example

Data: 40, 60, 80

HM=3140+160+180HM = \frac{3}{\frac{1}{40} + \frac{1}{60} + \frac{1}{80}}

=30.025+0.0167+0.0125= \frac{3}{0.025 + 0.0167 + 0.0125}

=30.0542=55.4= \frac{3}{0.0542} = 55.4

Compare to arithmetic mean: (40 + 60 + 80) / 3 = 60

The harmonic mean is always less than or equal to the arithmetic mean.

Properties

Relationship to Other Means

For positive numbers:

HM≀GM≀AMHM \leq GM \leq AM

Where GM is geometric mean and AM is arithmetic mean. Equality holds only when all values are identical.

Reciprocal Relationship

HM(x1,x2,…,xn)=1AM(1x1,1x2,…,1xn)HM(x_1, x_2, \ldots, x_n) = \frac{1}{AM\left(\frac{1}{x_1}, \frac{1}{x_2}, \ldots, \frac{1}{x_n}\right)}

Sensitivity to Small Values

Small values have disproportionate influence:

Values: 1, 100, 100, 100

Arithmetic mean: 75.25 Harmonic mean: 411+3100=41.03=3.88\frac{4}{\frac{1}{1} + \frac{3}{100}} = \frac{4}{1.03} = 3.88

One small value dramatically pulls down the harmonic mean.

Weighted Harmonic Mean

When values have different weights:

HMw=βˆ‘wiβˆ‘wixiHM_w = \frac{\sum w_i}{\sum \frac{w_i}{x_i}}

Example: Spend 100atstoreA(100 at store A (2/item) and 100atstoreB(100 at store B (5/item). What's the average price per item?

  • Items from A: 100/2 = 50 items
  • Items from B: 100/5 = 20 items
  • Total: 70 items for $200
  • Average price: 200/70 = $2.86/item

Using harmonic mean with equal weights (equal spending): HM=212+15=20.7=2.86HM = \frac{2}{\frac{1}{2} + \frac{1}{5}} = \frac{2}{0.7} = 2.86 βœ“

Applications

Finance

Average cost basis (dollar-cost averaging):

If you invest $1000 monthly regardless of share price, your average cost per share is the harmonic mean of the prices.

MonthPriceShares Bought
1$5020
2$4025
3$10010

Arithmetic mean price: 63.33Harmonicmean:63.33 Harmonic mean: \frac{3}{\frac{1}{50} + \frac{1}{40} + \frac{1}{100}} = 54.55$

Actual cost: 3000/55shares=3000 / 55 shares = 54.55 βœ“

Physics

  • Parallel resistors: Rtotal=1βˆ‘1RiR_{total} = \frac{1}{\sum \frac{1}{R_i}} (related to harmonic mean)
  • Lens equations
  • Average velocities for equal distances

Machine Learning

F1 Score is the harmonic mean of precision and recall:

F1=21precision+1recall=2Γ—PΓ—RP+RF_1 = \frac{2}{\frac{1}{\text{precision}} + \frac{1}{\text{recall}}} = \frac{2 \times P \times R}{P + R}

This penalizes models where precision and recall are unbalanced.

Biology

  • Effective population size in genetics
  • Average growth rates

Limitations

Undefined for Zero

If any value is zero, the harmonic mean is undefined (division by zero).

Workarounds:

  • Remove zeros if appropriate
  • Use a small positive value as substitute
  • Consider whether harmonic mean is appropriate for your data

Not Meaningful for Negative Values

Harmonic mean assumes positive values. Negative values can produce misleading results.

Sensitive to Outliers (Small Values)

Unlike arithmetic mean which is sensitive to large outliers, harmonic mean is extremely sensitive to small values.

Choosing the Right Mean

SituationMean to Use
General averagingArithmetic
Equal distances, different speedsHarmonic
Equal times, different speedsArithmetic
Growth ratesGeometric
Equal spending, different pricesHarmonic
Equal quantities, different pricesArithmetic
Ratios with fixed numeratorHarmonic

The Three Pythagorean Means

The arithmetic, geometric, and harmonic means are called the Pythagorean means, known since antiquity.

For two positive numbers a and b:

  • Arithmetic: a+b2\frac{a + b}{2}
  • Geometric: ab\sqrt{ab}
  • Harmonic: 2aba+b\frac{2ab}{a + b}

These satisfy: HMΓ—AM=GM2HM \times AM = GM^2

Historical Context

The harmonic mean was studied by the Pythagoreans in relation to musical harmonics. The name comes from its application to musical intervalsβ€”the harmonic mean of string lengths produces harmonious tones.

Archimedes and later mathematicians used all three Pythagorean means extensively in geometry and number theory.

Related Calculations

Summary

The harmonic mean is the reciprocal of the arithmetic mean of reciprocals. Use it when averaging rates where the numerator is constant: speeds over equal distances, prices for equal spending, or any ratio where denominators vary. The harmonic mean is always less than or equal to the geometric and arithmetic means. It's undefined for zero values and highly sensitive to small numbers. Common applications include average speeds, dollar-cost averaging, F1 scores, and parallel resistance calculations.