What is Harmonic Mean?
The harmonic mean is a type of average calculated as the reciprocal of the arithmetic mean of the reciprocals of the data values. It is particularly useful when dealing with rates, ratios, or situations where the average of rates is required. The formula is:
H = n / (∑ (1/xᵢ))
where n is the number of values, and xᵢ > 0.
For example, the harmonic mean of 2, 3, and 6 is 3 / (1/2 + 1/3 + 1/6) = 3 / (1) = 3.
Historical Background
The harmonic mean has been known since ancient times. The Pythagoreans (6th century BCE) studied three means: arithmetic, geometric, and harmonic. They defined the harmonic mean as the mean that preserves a certain musical harmony – hence the name. In music theory, the harmonic mean of two frequencies produces a pleasing interval. Over centuries, it found applications in geometry, physics, and statistics. Today it remains essential in fields ranging from electrical engineering to finance.
When to Use Harmonic Mean
-
Average speed (equal distances): If you travel equal distances at different speeds, the harmonic mean gives the correct average speed.
-
Parallel resistors / capacitors: The equivalent resistance of parallel resistors is the harmonic mean of individual resistances (when all are equal, otherwise a weighted harmonic mean).
-
Rates and ratios: In finance, the harmonic mean is used for averaging price multiples like P/E ratios.
-
Data with outliers: Harmonic mean is less sensitive to large outliers than arithmetic mean, but more sensitive to small ones.
Mathematical Properties
The harmonic mean possesses several important properties:
-
Inequality with other means: For any set of positive numbers, HM ≤ GM ≤ AM, with equality iff all numbers are equal.
-
Weighted harmonic mean: If numbers have weights wᵢ (positive), the weighted harmonic mean is H_w = (∑ wᵢ) / (∑ wᵢ/xᵢ). This is used, for example, when averaging rates with different durations.
-
Scale invariance: Multiplying all data by a constant multiplies the harmonic mean by the same constant.
-
Relationship with arithmetic mean of reciprocals: The harmonic mean is the reciprocal of the arithmetic mean of reciprocals.
Harmonic vs Arithmetic vs Geometric Mean
For positive numbers, the harmonic mean is always the smallest of the three Pythagorean means, followed by geometric, then arithmetic (HM ≤ GM ≤ AM). Equality holds only when all numbers are identical.
|
Property
|
Arithmetic Mean
|
Geometric Mean
|
Harmonic Mean
|
|
Formula
|
Σx / n
|
(Πx)1/n
|
n / Σ(1/x)
|
|
Sensitive to large outliers?
|
Yes
|
Moderate
|
Less
|
|
Sensitive to small values?
|
Less
|
Moderate
|
Yes (cannot handle zero)
|
|
Common use
|
General average
|
Growth rates
|
Rates, ratios, parallel systems
|
Case Study: Average Speed
Suppose you drive from city A to B at 60 km/h and return at 40 km/h over the same distance. What is your average speed for the round trip? The arithmetic mean (50 km/h) is incorrect because you spend more time at the slower speed. The correct average speed is the harmonic mean: 2 / (1/60 + 1/40) = 2 / (0.01667 + 0.025) = 2 / 0.04167 ≈ 48 km/h. This reflects the true time-weighted average.
Weighted Harmonic Mean in Practice
In many real-world situations, observations have different weights. For example, if you travel different distances at different speeds, you need the weighted harmonic mean to find the average speed. Suppose you drive 100 km at 60 km/h and 200 km at 40 km/h. The total time is 100/60 + 200/40 ≈ 1.667 + 5 = 6.667 h, total distance 300 km, average speed = 300/6.667 ≈ 45 km/h. Using weighted harmonic mean: weights are distances, H = (100+200) / (100/60 + 200/40) = 300 / (1.667+5) = 300/6.667 = 45 km/h. This matches.
Step-by-Step Calculation
-
Compute reciprocals: For each number xᵢ, calculate 1/xᵢ.
-
Sum the reciprocals: S = Σ (1/xᵢ).
-
Divide n by S: H = n / S.
All values must be positive. If any value is zero or negative, the harmonic mean is undefined.
Programming Implementation
In most programming languages, calculating the harmonic mean is straightforward. For example, in Python:
def harmonic_mean(data):
n = len(data)
if n == 0 or any(x <= 0 for x in data):
return None # or raise exception
sum_recip = sum(1.0 / x for x in data)
return n / sum_recip
In JavaScript (exactly as used in this calculator), the logic is similar. The key is to handle zero and negative values gracefully.
Handling Special Cases
-
Zero: Cannot be included because reciprocal is infinite.
-
Negative numbers: The harmonic mean can be defined for negative numbers if the sum of reciprocals is negative, but interpretation is rare. Our calculator only accepts positive numbers.
-
Large datasets: The calculation is straightforward and numerically stable for positive numbers.
Common Misconceptions
-
Harmonic mean can be used for any data: While technically computable for positive numbers, it is only meaningful for rates and ratios. Using it for general data (like test scores) yields a value that may not represent the data well.
-
Harmonic mean is always smaller than arithmetic: True for positive numbers, but if negative numbers are allowed, this inequality may reverse. Standard practice restricts to positives.
-
Harmonic mean of rates requires equal weights: In many cases, weights (like time or distance) must be considered; otherwise, the simple harmonic mean applies only when the denominator of each rate is constant.
Applications in Different Fields
-
Physics / Engineering: Equivalent resistance for parallel circuits, average density when masses are equal.
-
Finance: Average of price-to-earnings ratios in a portfolio (harmonic mean gives more weight to lower ratios).
-
Data science: F1-score in machine learning is the harmonic mean of precision and recall.
-
Environmental science: Average of rates (e.g., flow rates).
-
Music theory: The harmonic mean of two frequencies produces a consonant interval (e.g., perfect fifth).
Reviewed by Alex Chen – Data Scientist and statistician with 10+ years experience in quantitative analysis. Alex ensures our statistical tools meet academic and professional standards.
Last updated: March 2026
Frequently Asked Questions
The harmonic mean is defined as the reciprocal of the average of reciprocals. If any value is zero, its reciprocal is infinite, making the harmonic mean zero (or undefined). Negative values can yield a result, but interpretation is ambiguous and rarely used. For practical applications, positive numbers are required.
When dealing with rates or ratios where the denominator varies. For example, average speed over equal distances, average resistance in parallel circuits, or average of price multiples in finance. In these cases, the harmonic mean gives the correct aggregate.
Technically, you can compute the harmonic mean for any set of positive numbers. However, it is most meaningful when the data are naturally rates or ratios. For general data, the arithmetic or geometric mean may be more appropriate.
F1-score is the harmonic mean of precision and recall. It balances the two metrics, giving a value that is high only when both are high. This is a classic use of harmonic mean in machine learning.
For a single number, the harmonic mean equals that number. This is consistent because 1 / (1/x) = x.
Yes, for any set of positive numbers, the harmonic mean is less than or equal to the geometric mean, with equality only when all numbers are equal. This is a well-known inequality (HM ≤ GM ≤ AM).