Harmonic Mean Calculator
Calculate mean for rates and ratios.
Enter numbers separated by commas, spaces, or newlines
Enter your data to see results
What Is the Harmonic Mean?
The harmonic mean is the reciprocal of the arithmetic mean of reciprocals:
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):
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.
| Stock | P/E Ratio | Earnings |
|---|---|---|
| A | 10 | $100M |
| B | 20 | $100M |
Arithmetic mean P/E: 15 Harmonic mean P/E:
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
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:
Where GM is geometric mean and AM is arithmetic mean. Equality holds only when all values are identical.
Reciprocal Relationship
Sensitivity to Small Values
Small values have disproportionate influence:
Values: 1, 100, 100, 100
Arithmetic mean: 75.25 Harmonic mean:
One small value dramatically pulls down the harmonic mean.
Weighted Harmonic Mean
When values have different weights:
Example: Spend 2/item) and 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): β
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.
| Month | Price | Shares Bought |
|---|---|---|
| 1 | $50 | 20 |
| 2 | $40 | 25 |
| 3 | $100 | 10 |
Arithmetic mean price: \frac{3}{\frac{1}{50} + \frac{1}{40} + \frac{1}{100}} = 54.55$
Actual cost: 54.55 β
Physics
- Parallel resistors: (related to harmonic mean)
- Lens equations
- Average velocities for equal distances
Machine Learning
F1 Score is the harmonic mean of precision and recall:
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
| Situation | Mean to Use |
|---|---|
| General averaging | Arithmetic |
| Equal distances, different speeds | Harmonic |
| Equal times, different speeds | Arithmetic |
| Growth rates | Geometric |
| Equal spending, different prices | Harmonic |
| Equal quantities, different prices | Arithmetic |
| Ratios with fixed numerator | Harmonic |
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:
- Geometric:
- Harmonic:
These satisfy:
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
- Mean Calculator β Arithmetic mean
- Geometric Mean Calculator β Mean for growth rates
- Weighted Average Calculator β Weighted arithmetic mean
- Coefficient of Variation Calculator β Relative variability
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.