The harmonic mean is the reciprocal of the arithmetic mean of the reciprocals of a set of values. For n positive values x₁, x₂, …, xₙ:
Use the harmonic mean when averaging a rate — something measured as "X per Y" — and the denominator Y stays the same across all observations. It is always the smallest of the three Pythagorean means: HM ≤ GM ≤ AM.
Harmonic Mean Calculator
Enter your values below. The calculator shows the harmonic mean, arithmetic mean, and geometric mean side by side, with full step-by-step working.
For discrete data: enter the value X and its frequency f. For continuous data: enter the lower and upper class boundaries — the calculator uses the midpoint automatically.
| # | Value (X) | Frequency (f) |
|---|---|---|
| 1 | ||
| 2 | ||
| 3 | ||
| 4 |
Enter each value (e.g. a P/E ratio) and its corresponding weight (e.g. market cap). WHM = Σw / Σ(w/x).
| # | Value (x) | Weight (w) |
|---|---|---|
| 1 | ||
| 2 | ||
| 3 |
What Is the Harmonic Mean?
The harmonic mean is one of the three Pythagorean means, alongside the arithmetic mean and the geometric mean. It was recognized in ancient Greek mathematics and named through its relationship to musical harmonics and proportional sequences.
As a part of descriptive statistics, the harmonic mean sits alongside other measures of central tendency — but it has a narrower, more specific job: it gives the correct average for rate data where you're dividing one quantity by another and the denominator is held fixed.
The "Invert–Average–Invert" Method
The harmonic mean performs exactly three steps on any dataset:
- Take the reciprocal of each value: 1/x₁, 1/x₂, … 1/xₙ
- Calculate the arithmetic mean of those reciprocals
- Take the reciprocal of that arithmetic mean
That three-step sequence is the whole idea. Because a rate and its reciprocal contain the same information — 60 km/h and 1/60 h/km describe the same speed — inverting before averaging ensures the time element receives proper weight rather than being ignored.
Why the Arithmetic Mean Fails for Rates
Here's the core problem. Suppose you drive 60 km at 30 km/h, then 60 km at 60 km/h. Each leg covers the same distance.
Arithmetic mean of speeds: (30 + 60) ÷ 2 = 45 km/h
At 45 km/h, 120 km would take 120 ÷ 45 = 2.67 hours.
The actual time: 60/30 + 60/60 = 2 + 1 = 3 hours. Actual average speed = 120 ÷ 3 = 40 km/h.
The arithmetic mean overstates the average by 5 km/h because it ignores how much more time you spend on the slower leg. The harmonic mean: 2 ÷ (1/30 + 1/60) = 2 ÷ 0.05 = 40 km/h ✓
The arithmetic mean is correct when equal time is spent at each rate. The harmonic mean is correct when equal distance (or any fixed denominator quantity) is spent at each rate. The difference is which quantity stays constant.
Harmonic Mean Formula
General Formula — Ungrouped Data
For n positive values x₁, x₂, x₃, …, xₙ:
n = number of values
Σ(1/xᵢ) = sum of all reciprocals
Step-by-step procedure: (1) Take the reciprocal of each value. (2) Add all the reciprocals together. (3) Divide n by that sum.
Special Case: Two Numbers
For two positive values a and b, the general formula simplifies to a clean shortcut that appears frequently in physics and finance:
40
Special Case: Three Numbers
For three positive values a, b, c (derived by applying the general formula with n = 3):
Weighted Harmonic Mean
When observations carry unequal weights — as in a portfolio where stocks differ in market cap — the unweighted formula gives wrong results. The weighted harmonic mean accounts for each observation's relative importance:
wᵢ = weight for observation i
xᵢ = value for observation i
Proof of the Formula
The arithmetic mean of the reciprocals of x₁, x₂, …, xₙ is:
Derivation
AM of reciprocals = (1/x₁ + 1/x₂ + … + 1/xₙ) / n = Σ(1/xᵢ) / nThe harmonic mean is the reciprocal of this quantity:
HM = 1 / [Σ(1/xᵢ)/n] = n / Σ(1/xᵢ)This confirms that the harmonic mean is the reciprocal of the arithmetic mean of the reciprocals — which is its defining property.
How to Calculate the Harmonic Mean: Worked Examples
Find the harmonic mean of 4, 8, 16, 32.
Count: n = 4 values.
Reciprocals:
1/4 = 0.2500
1/8 = 0.1250
1/16 = 0.0625
1/32 = 0.03125
Sum of reciprocals: 0.2500 + 0.1250 + 0.0625 + 0.03125 = 0.46875
HM = n / sum: 4 / 0.46875 = 8.5333
HM = 8.53 | GM = (4×8×16×32)^(1/4) = 16384^0.25 = 11.31 | AM = 60/4 = 15.00
Confirm: HM (8.53) ≤ GM (11.31) ≤ AM (15.00) ✓
HM ≤ GM ≤ AM — Visualized for the dataset {4, 8, 16, 32}
A car travels 300 km: first 100 km at 60 km/h, second 100 km at 80 km/h, final 100 km at 120 km/h. What is the average speed?
Since each leg covers the same distance (100 km), the denominator is fixed — use the harmonic mean.
Reciprocals of speeds: 1/60 = 0.016667, 1/80 = 0.012500, 1/120 = 0.008333
Sum of reciprocals: 0.016667 + 0.012500 + 0.008333 = 0.037500
HM = 3 / 0.037500 = 80 km/h
✓ Verification: total time = 100/60 + 100/80 + 100/120 = 1.667 + 1.250 + 0.833 = 3.75 hours. Average speed = 300 ÷ 3.75 = 80 km/h ✓
The arithmetic mean (86.67 km/h) gives the wrong answer.
A portfolio holds equal dollar amounts in three stocks with P/E ratios of 10, 20, and 40. What is the average P/E?
Equal dollar investment means you buy different numbers of shares — the investment amount (dollars) is the fixed denominator, so the harmonic mean applies.
Reciprocals: 1/10 = 0.1000, 1/20 = 0.0500, 1/40 = 0.0250
Sum of reciprocals: 0.1000 + 0.0500 + 0.0250 = 0.1750
HM = 3 / 0.1750 = 17.14
✓ The harmonic mean (17.14) reflects the actual earnings-per-dollar of the portfolio. The arithmetic mean (23.33) overstates it because the high P/E stock pulls it up regardless of how few shares you bought at that price.
A model achieves Precision = 0.90, Recall = 0.30. Calculate the F1 score.
The F1 score is the harmonic mean of precision and recall: F1 = 2 × (P × R) / (P + R), which is the two-number formula HM = 2ab/(a+b).
F1 = 2 × (0.90 × 0.30) / (0.90 + 0.30) = 2 × 0.27 / 1.20 = 0.54 / 1.20 = 0.45
Arithmetic mean: (0.90 + 0.30) / 2 = 0.60
✓ The arithmetic mean (0.60) suggests the model is decent. The harmonic mean (F1 = 0.45) shows the real problem: recall so low that the model misses 70% of positive cases. The harmonic mean punishes imbalance; the arithmetic mean hides it.
Harmonic Mean for Grouped Data
Exam questions and real datasets often present data as a frequency distribution rather than raw values. The harmonic mean formula adjusts accordingly for each of the three series types.
Type 1: Individual Series (Raw / Ungrouped Values)
N = number of observations
X = each individual value
| X | 1/X |
|---|---|
| 2 | 0.5000 |
| 4 | 0.2500 |
| 5 | 0.2000 |
| 8 | 0.1250 |
| 10 | 0.1000 |
| N = 5 | Σ(1/X) = 1.1750 |
HM = 5 / 1.1750 = 4.2553
Type 2: Discrete Frequency Distribution
f = frequency of each value X
Σf = total frequency (n)
Discrete Example — Worked in Full
| Value (X) | Frequency (f) | f/X |
|---|---|---|
| 10 | 3 | 3/10 = 0.3000 |
| 20 | 5 | 5/20 = 0.2500 |
| 40 | 2 | 2/40 = 0.0500 |
| 50 | 4 | 4/50 = 0.0800 |
| Total | Σf = 14 | Σ(f/X) = 0.6800 |
HM = Σf / Σ(f/X) = 14 / 0.6800 = 20.588
Type 3: Continuous Frequency Distribution
For class intervals, calculate the class midpoint X̄ = (lower limit + upper limit) / 2, then substitute X̄ for X in the same formula.
X̄ = class midpoint = (lower + upper) / 2
Continuous Example — Worked in Full
| Class Interval | Midpoint X̄ | Frequency f | f/X̄ |
|---|---|---|---|
| 10–20 | 15 | 4 | 4/15 = 0.2667 |
| 20–30 | 25 | 6 | 6/25 = 0.2400 |
| 30–40 | 35 | 5 | 5/35 = 0.1429 |
| 40–50 | 45 | 3 | 3/45 = 0.0667 |
| Total | — | Σf = 18 | Σ(f/X̄) = 0.7163 |
HM = 18 / 0.7163 = 25.13
Summary Table — All Three Series Types
| Series Type | Formula | When to Use |
|---|---|---|
| Individual / Ungrouped | HM = N / Σ(1/X) | Raw list of distinct values |
| Discrete Frequency | HM = Σf / Σ(f/X) | Values with assigned frequencies |
| Continuous Frequency | HM = Σf / Σ(f/X̄) | Class intervals; use midpoint X̄ |
Weighted Harmonic Mean
The plain harmonic mean treats each observation equally. The weighted version lets you assign different importance to different values — which is essential when portfolio positions, market caps, or sample sizes differ.
wᵢ = weight for observation i (e.g. market cap)
xᵢ = rate value (e.g. P/E ratio)
Three stocks with different market caps and P/E ratios.
| Stock | Market Cap ($bn) | P/E Ratio | w / x |
|---|---|---|---|
| A | 100 | 15 | 100/15 = 6.667 |
| B | 200 | 25 | 200/25 = 8.000 |
| C | 50 | 10 | 50/10 = 5.000 |
| Total | Σw = 350 | — | Σ(w/x) = 19.667 |
WHM = Σw / Σ(w/x) = 350 / 19.667 = 17.80
Unweighted arithmetic mean = (15+25+10)/3 = 16.67 — does not account for market cap sizes.
Unweighted harmonic mean = 3/(1/15+1/25+1/10) = 3/0.207 = 14.49 — ignores that Stock B is four times larger than Stock C.
✓ The weighted harmonic mean (17.80) gives the index's true P/E by accounting for each stock's actual share of the index.
When to Use the Harmonic Mean
The Constant-Denominator Rule
There is one clean decision rule that covers every real-world application:
Rate = "something per something." Fixed denominator = same distance, same budget, same number of samples. When those conditions hold, the arithmetic mean will give you an answer that's too high.
| Scenario | Fixed Denominator | Correct Mean |
|---|---|---|
| Average speed over equal distances | Distance is constant | Harmonic Mean |
| Average P/E ratio with equal dollar investment | Dollar investment is constant | Harmonic Mean |
| F1 score (precision + recall) | Number of test samples is constant | Harmonic Mean |
| Parallel resistors equivalent resistance | Voltage is constant | Harmonic Mean |
| Fuel efficiency for equal distances traveled | Distance is constant | Harmonic Mean |
| Average speed over equal time intervals | Time is constant (not distance) | Arithmetic Mean |
| Average annual investment return | Returns compound, not rate-based | Geometric Mean |
| Average test scores | Additive quantities, no "per" structure | Arithmetic Mean |
| P/E ratios weighted by unequal market caps | Different dollar amounts | Weighted HM |
Decision Flowchart
Are values multiplicative / compounding?
Yes → Geometric Mean
No → Arithmetic Mean
Is the denominator of the rate held constant?
Yes → Harmonic Mean
No → Weighted Harmonic Mean (or check context)
When the Three Means Agree — and When They Diverge
All three Pythagorean means are equal when all data values are identical. As values spread apart, the gap widens. The table below shows this for three datasets:
| Dataset | AM | GM | HM | AM − HM |
|---|---|---|---|---|
| 5, 5, 5, 5 | 5.00 | 5.00 | 5.00 | 0.00 |
| 1, 5, 25 | 10.33 | 5.00 | 2.47 | 7.86 |
| 1, 100 | 50.50 | 10.00 | 1.98 | 48.52 |
A large gap between AM and HM signals a right-skewed distribution. The HM gives much smaller values than the AM when data contains a mix of large and very small values.
Properties of the Harmonic Mean
For any set of positive real numbers that are not all equal, the harmonic mean is strictly less than the geometric mean, which is strictly less than the arithmetic mean. When all values are equal, all three means coincide.
For any two positive numbers a and b: (Arithmetic Mean) × (Harmonic Mean) = (Geometric Mean)². This is an exact algebraic identity, not an approximation. It means the geometric mean is the geometric mean of the arithmetic and harmonic means.
Because the formula requires reciprocals, any zero value makes 1/x undefined. The harmonic mean cannot be computed for datasets containing zeros. For negative values, the reciprocal changes sign in ways that make the result meaningless for rate averaging.
The reciprocal of a small number is large, so small values dominate the sum of reciprocals and pull the HM down sharply. Example: HM of {100, 100, 100, 1} = 4/(0.03 + 1) ≈ 3.88, far below AM = 75.25. A single small value can dramatically lower the harmonic mean.
Like the arithmetic and geometric means, the harmonic mean incorporates every value. No observation is discarded. This is a strength for rate averaging (all legs of a trip matter) and also the reason a single zero makes it impossible to compute.
There is exactly one harmonic mean for a given set of positive values. Unlike the mode, which may be absent or multiple, the HM always produces a single unambiguous result.
Multiplying every value in the dataset by a constant k multiplies the harmonic mean by k as well. The relative structure of the data is preserved.
If all xᵢ = c, then HM = n ÷ (n/c) = c. The harmonic mean of identical values equals those values, consistent with all other means.
Because large values have small reciprocals, they contribute little to the sum Σ(1/xᵢ). A single very large value barely moves the harmonic mean, making it robust in the high-value direction (the opposite of the arithmetic mean, which is sensitive to high outliers).
The AM × HM = GM² Identity — Proof
Algebraic Proof for Two Numbers a and b
AM = (a + b) / 2 GM = √(ab) HM = 2ab / (a + b) AM × HM = [(a+b)/2] × [2ab/(a+b)] = 2ab(a+b) / [2(a+b)] = ab GM² = (√ab)² = abTherefore: AM × HM = GM²
Numerical check: a = 4, b = 9 → AM = 6.5, GM = 6, HM = 72/13 ≈ 5.538
AM × HM = 6.5 × 5.538 = 36.0 = GM² = 6² = 36 ✓
Advantages and Disadvantages of the Harmonic Mean
| Advantages | Disadvantages |
|---|---|
| Mathematically rigorous and uniquely defined for positive data | Cannot handle zero values — the formula breaks down entirely |
| Uses every observation in the dataset | Not applicable to negative values in standard rate problems |
| Gives the correct average for rates and ratios with a fixed denominator | Gives excessive weight to very small values, which can distort results if small values are measurement errors |
| Resistant to inflated high values, unlike the arithmetic mean | Less intuitive than the arithmetic mean — the concept of "reciprocal of average reciprocals" is unfamiliar to most people |
| Amenable to algebraic treatment (AM × HM = GM²) | Requires knowing whether the denominator is truly fixed — wrong application gives wrong answers |
| Well-defined for grouped data through HM = Σf / Σ(f/X) | Cannot be computed when any value is unknown — a single missing entry prevents calculation |
Real-World Applications of the Harmonic Mean
Average Speed — Transportation
When a vehicle covers equal distances at different speeds, the average speed is the harmonic mean. The classic exam question. Using the arithmetic mean gives a figure that's always too high because more time is spent at the slower speed.
P/E Ratio — Portfolio Analysis
CFA candidates and portfolio managers use the harmonic mean for P/E ratios when equal dollar amounts are invested in each stock. With unequal weights, they use the weighted harmonic mean. This is a standard calculation in equity research.
F1 Score — Machine Learning
The F1 score is the harmonic mean of precision and recall. It is the standard combined metric for binary classifiers in NLP, medical diagnosis, and fraud detection — any task where both false positives and false negatives are costly.
Parallel Resistors — Physics
For n resistors in parallel: 1/Req = 1/R₁ + 1/R₂ + … + 1/Rₙ, which rearranges to Req = HM(R₁, …, Rₙ) ÷ n. For two resistors in parallel: Req = HM(R₁, R₂) ÷ 2 = R₁R₂/(R₁+R₂). The same logic applies to capacitors in series and thin lenses.
Effective Population Size — Genetics
When a population fluctuates over generations, the effective population size Nₑ is the harmonic mean of census sizes across generations. A single bottleneck (small population one year) dramatically reduces Nₑ. Conservation biologists rely on this to assess extinction risk.
Fuel Efficiency
When comparing MPG figures for a fleet over equal distances, use the harmonic mean. A vehicle getting 25 MPG burns far more fuel per mile than one getting 100 MPG, so the low-efficiency vehicle correctly dominates the average.
Cost of Capital — Corporate Finance
In Weighted Average Cost of Capital (WACC) calculations, blending rates of return across capital tranches of different sizes calls for the weighted harmonic mean when the rates are expressed as ratios over a consistent base.
Population Genetics — Worked Example
Population sizes over 5 generations: 1000, 100, 1000, 1000, 1000. Find effective population size Nₑ.
Reciprocals: 1/1000, 1/100, 1/1000, 1/1000, 1/1000 = 0.001, 0.010, 0.001, 0.001, 0.001
Sum of reciprocals: 0.001 + 0.010 + 0.001 + 0.001 + 0.001 = 0.014
Nₑ = HM = 5 / 0.014 = 357
✓ The arithmetic mean gives 820, implying a healthy population. The harmonic mean gives 357 — far below the apparent average — because one bottleneck generation (100 individuals) restricts gene flow for all subsequent generations. This is why single bad years matter so much in conservation biology.
Harmonic Mean vs Arithmetic Mean vs Geometric Mean
The three Pythagorean means each have a defining operation and a natural application domain. Choosing the wrong one for your data type produces systematically incorrect results, not just imprecise ones.
| Property | Arithmetic Mean (AM) | Geometric Mean (GM) | Harmonic Mean (HM) |
|---|---|---|---|
| Formula | (Σxᵢ) / n | (∏xᵢ)^(1/n) | n / Σ(1/xᵢ) |
| Core operation | Sum → divide | Multiply → root | Invert → average → invert |
| Best for | Additive quantities (scores, temps) | Multiplicative processes (returns, growth) | Rates with fixed denominator (speed, P/E) |
| Sensitive to | High outliers (pulled up) | High values (less than AM) | Low outliers (pulled down sharply) |
| Zero values allowed? | Yes | No (product becomes 0) | No (reciprocal undefined) |
| Negative values? | Yes | Not for standard form | Not for rate applications |
| Relative size | Largest | Middle | Smallest |
Data: 1, 2, 4, 8
AM = (1+2+4+8) / 4 = 15 / 4 = 3.75
GM = (1×2×4×8)^(1/4) = 64^0.25 = 2.83
HM = 4 / (1 + 0.5 + 0.25 + 0.125) = 4 / 1.875 = 2.13
✓ Confirm: 2.13 ≤ 2.83 ≤ 3.75. The equality HM = GM = AM holds only when all values are identical.
How to Calculate Harmonic Mean in Excel
Excel provides a built-in function: HARMEAN. It accepts individual values, cell ranges, or a mix of both.
| Task | Excel Formula | Notes |
|---|---|---|
| Harmonic mean of a range | =HARMEAN(A1:A10) | All values must be positive; returns #NUM! for zeros |
| Harmonic mean of listed values | =HARMEAN(10, 20, 30, 40) | Up to 255 arguments |
| Speed example (B2=60, B3=80, B4=100) | =HARMEAN(B2:B4) | Returns 76.19 — the correct average speed |
| Compare with arithmetic mean | =AVERAGE(A1:A10) | Always ≥ HARMEAN result |
| Compare with geometric mean | =GEOMEAN(A1:A10) | Always between HARMEAN and AVERAGE |
HARMEAN returns a #NUM! error if any value in the range is zero or negative. Check your data for these values before applying the function. The function also ignores text and logical values silently, so verify your range contains only numbers.
Harmonic Mean in Python and R
Python
import statistics data = [10, 20, 40, 80] hm = statistics.harmonic_mean(data) print(hm) # 23.18181... # Raises StatisticsError if any value is zero or negative
from scipy.stats import hmean import numpy as np data = np.array([10, 20, 40, 80]) hm = hmean(data) print(f"Harmonic mean: {hm:.4f}") # 23.1818 # Manual calculation — same result hm_manual = len(data) / np.sum(1 / data) print(f"Manual: {hm_manual:.4f}") # 23.1818
import numpy as np # P/E ratios and market caps values = np.array([15, 25, 10]) # P/E ratios weights = np.array([100, 200, 50]) # market cap ($bn) whm = np.sum(weights) / np.sum(weights / values) print(f"Weighted HM: {whm:.4f}") # 17.8sWith # Grouped data: HM = Σf / Σ(f/x) x = np.array([10, 20, 40, 50]) # values f = np.array([3, 5, 2, 4]) # frequencies hm_grouped = np.sum(f) / np.sum(f / x) print(f"Grouped HM: {hm_grouped:.4f}") # 20.5882
R
# Using the psych package library(psych) data <- c(10, 20, 40, 80) harmonic.mean(data) # [1] 23.18182 # Base R — no package needed hm <- length(data) / sum(1/data) cat("Harmonic mean:", hm, "\n") # 23.18182 # Weighted harmonic mean values <- c(15, 25, 10) weights <- c(100, 200, 50) whm <- sum(weights) / sum(weights / values) cat("Weighted HM:", whm, "\n") # 17.8sWith
Harmonic Progression — Brief Overview
A harmonic progression (HP) is a sequence of numbers whose reciprocals form an arithmetic progression. It is a related but distinct concept from the harmonic mean.
If a, b, c, d, … is an arithmetic progression (AP) with first term a and common difference d, then the corresponding harmonic progression is:
Key property: In a harmonic progression, any term Hₙ is the harmonic mean of its two neighbors: Hₙ = HM(Hₙ₋₁, Hₙ₊₁). This is what gives the sequence its name.
The special case 1, 1/2, 1/3, 1/4, 1/5, … is the harmonic series. Its partial sums grow without bound (the series diverges), a result that surprises many students who expect a series of decreasing terms to converge.
To identify a harmonic progression, check whether the reciprocals form an AP (constant common difference). The harmonic mean itself is a single-number summary, not a sequence. These two concepts connect through reciprocals but are tested differently.
Common Harmonic Mean Mistakes
The speed problem is the most common exam trap. Arithmetic mean of speeds over equal distances is always too high. If the same distance is covered at each speed, it must be the harmonic mean.
Writing Σxᵢ in the denominator instead of Σ(1/xᵢ). The formula requires summing reciprocals — the actual values never appear directly in the denominator of the final expression.
If a car travels for equal amounts of time at different speeds, the arithmetic mean is correct. Only equal distance calls for the harmonic mean. When all values are identical the distinction doesn't matter, but it matters in every real problem.
Any zero in the dataset makes HM undefined. If zero appears, the harmonic mean cannot be computed. Report this explicitly rather than trying to work around it.
When portfolio weights differ, the unweighted formula gives wrong results. Confirm whether your situation involves equal or unequal amounts of the denominator quantity before choosing the formula.
Multi-period investment returns compound multiplicatively — that's the geometric mean's territory. The harmonic mean is for rates where the denominator is fixed, not for compounding over time.
Rounding 1/3 to 0.33 instead of keeping 0.3333 introduces cumulative error across multiple reciprocals. Keep full precision through the entire calculation and round only the final answer.
These are related through reciprocals but are distinct concepts. The harmonic mean is a single average value. The harmonic progression is a sequence defined by its reciprocals forming an AP. They appear in different types of exam questions.
Frequently Asked Questions
The harmonic mean is the reciprocal of the arithmetic mean of the reciprocals of a set of positive values. For n values: HM = n / (1/x₁ + 1/x₂ + … + 1/xₙ). It is one of the three Pythagorean means and is the appropriate average for rates and ratios where the denominator of the rate stays constant across observations.
The general formula is HM = n / Σ(1/xᵢ): count the number of values, then divide by the sum of their reciprocals. For two numbers a and b, this simplifies to HM = 2ab / (a + b). For grouped data with frequencies: HM = Σf / Σ(f/X).
For any two positive numbers a and b, HM = 2ab / (a + b). This is the same as saying the harmonic mean is twice their product divided by their sum. Example: HM(30, 60) = 2 × 30 × 60 / (30 + 60) = 3600 / 90 = 40.
For three positive numbers a, b, c: HM = 3abc / (ab + bc + ca). This is derived by applying the general formula with n = 3. Alternatively, calculate 3 / (1/a + 1/b + 1/c) directly.
The arithmetic mean sums all values and divides by the count — correct for additive quantities like test scores. The harmonic mean inverts each value, averages the reciprocals, then inverts back — correct for rates where the denominator is fixed. For the same dataset, HM ≤ AM, with the gap widening as values become more spread out or asymmetric.
The geometric mean is the nth root of the product of n values — used for multiplicative or compounding data like investment returns. The harmonic mean involves reciprocals and is used for rates with a fixed denominator. Both are always less than the arithmetic mean for unequal positive values, but HM ≤ GM ≤ AM in strict order.
The three Pythagorean means are the arithmetic mean (AM), geometric mean (GM), and harmonic mean (HM). They satisfy HM ≤ GM ≤ AM for any set of positive numbers that are not all equal. Each one corresponds to a different kind of average: additive (AM), multiplicative (GM), and rate-based (HM).
The name comes from the connection to harmonic series in music. The frequencies of overtones in a musical note — the fundamental plus harmonics — are in arithmetic progression, so their reciprocals (wavelengths) form a harmonic progression. The mean that naturally describes this reciprocal relationship became the harmonic mean.
Start with your values, say 10, 20, 40. Take their reciprocals: 1/10, 1/20, 1/40. Find the arithmetic mean of those reciprocals: (1/10 + 1/20 + 1/40) / 3 = 0.175 / 3 = 0.0583. The harmonic mean is the reciprocal of that result: 1 / 0.0583 = 17.14. That three-step process is the defining property.
It is a three-word mnemonic for calculating the harmonic mean: (1) Invert each value by taking its reciprocal. (2) Average those reciprocals using the arithmetic mean. (3) Invert the result. The final number is the harmonic mean. This sequence correctly handles rate data because inverting speeds gives times, averaging times is correct, and inverting back gives the average speed.
HM = N / Σ(1/X), where N is the number of values and X represents each individual value. Sum all the reciprocals of the data values, then divide N by that sum. All values must be positive.
For a discrete frequency distribution: HM = Σf / Σ(f/X). For a continuous frequency distribution: HM = Σf / Σ(f/X̄), where X̄ is the class midpoint = (lower + upper limit) / 2. In both cases, divide the total frequency by the sum of frequency-over-value terms.
HM = Σf / Σ(f/X). Create a column of f/X values by dividing each frequency by its corresponding value. Sum all f/X values to get Σ(f/X). Sum all frequencies to get Σf. Then HM = Σf ÷ Σ(f/X).
HM = Σf / Σ(f/X̄). The only change from the discrete formula is that you use the class midpoint X̄ = (lower + upper limit) ÷ 2 in place of a discrete value. This applies to data presented as class intervals such as 10–20, 20–30, etc.
WHM = Σwᵢ / Σ(wᵢ/xᵢ), where wᵢ is the weight assigned to value xᵢ. Sum all the weights for the numerator. For each value, multiply its weight by its reciprocal to get wᵢ/xᵢ, then sum those for the denominator.
Step 1: Confirm all values are positive. Step 2: Calculate the reciprocal 1/xᵢ for each value. Step 3: Add all reciprocals: Σ(1/xᵢ). Step 4: Count the values: n. Step 5: HM = n ÷ Σ(1/xᵢ). Keep full precision on reciprocals throughout; round only the final answer.
Use =HARMEAN(range). For example, if speeds are in A1:A5, enter =HARMEAN(A1:A5). The function accepts up to 255 arguments. It returns a #NUM! error if any value is zero or negative, so clean your data first. HARMEAN is in every version of Excel from 97 onwards.
The function is HARMEAN, spelled in full with no abbreviation. Syntax: =HARMEAN(number1, [number2], …). You can pass individual cells, comma-separated values, or a cell range. There is no equivalent shortcut or abbreviation; HARMEAN is the only built-in option.
Three options: (1) statistics.harmonic_mean(data) from Python's standard library. (2) scipy.stats.hmean(data) from SciPy. (3) Manual: len(data) / sum(1/x for x in data). With NumPy: len(data) / np.sum(1/np.array(data)). All produce identical results for positive data.
Using the psych package: harmonic.mean(data). Base R without any package: length(data) / sum(1/data). For grouped data: sum(f) / sum(f/x) where f and x are frequency and value vectors.
Yes, for any set of positive values that are not all identical: HM < AM. When all values are equal, HM = GM = AM. This is part of the Pythagorean means inequality: HM ≤ GM ≤ AM. The gap widens as values become more spread out.
For two positive numbers a and b, the product of their arithmetic mean and harmonic mean equals the square of their geometric mean: AM × HM = GM². Proof: AM = (a+b)/2, HM = 2ab/(a+b), so AM × HM = [(a+b)/2] × [2ab/(a+b)] = ab = (√ab)² = GM². This is an exact identity, not an approximation.
When all values equal some constant c, the harmonic mean also equals c. This is consistent with all means: HM = n / (n/c) = c. The HM ≤ GM ≤ AM inequality becomes an equality (all three equal c) when and only when all values are identical.
Because smaller values have larger reciprocals. The reciprocal of 1 is 1, but the reciprocal of 0.1 is 10. When you sum reciprocals, the small values dominate the total. That large sum in the denominator of n/Σ(1/xᵢ) produces a small HM, pulled strongly toward the small values in your dataset.
Not in its standard definition, which requires all values to be positive. If a dataset contains negative values, some reciprocals are negative, and the formula can produce misleading or meaningless results for rate applications. The harmonic mean is defined for strictly positive values.
Effectively, no. For positive values, HM = n / Σ(1/xᵢ) is always positive. If a zero were included, 1/0 is undefined and the formula cannot be evaluated. The result cannot be zero from positive inputs.
No. A zero value makes 1/x undefined — you cannot take the reciprocal of zero. The harmonic mean is undefined for any dataset that contains a zero. This is not a rounding or precision issue; it is a fundamental mathematical constraint. If your data contains zeros, the HM cannot be computed.
Use the harmonic mean when you are averaging a rate — something expressed as "X per Y" — and the denominator Y is the same for all observations. The clearest cases: average speed over equal distances, average P/E with equal dollar investment, the F1 score, and parallel resistors. If the denominator varies across observations, use the weighted harmonic mean instead.
Arithmetic mean: when values are additive quantities (heights, scores, prices) or when equal time is spent at each rate. Harmonic mean: when values are rates with a fixed denominator, equal distance is covered at each speed, or equal amounts of money are invested at each P/E ratio. The easiest test: does adding more time at a slow rate change the total time more than expected? If yes, use the harmonic mean.
Geometric mean: compounding or multiplicative processes — investment returns over multiple years, population growth rates, ratios that multiply together. Harmonic mean: rate data where the denominator is held fixed — speed over equal distances, efficiency ratios, the F1 score. Neither is used for additive quantities; that's the arithmetic mean's domain.
Because travel time for a given distance = distance ÷ speed, and the total time for equal distances is proportional to the sum of reciprocals of the speeds. The harmonic mean accounts for the fact that you spend more time at slower speeds — it weights each speed by the time spent at it, not equally. The arithmetic mean ignores this and gives an answer that is always too high when speeds differ.
The F1 score measures a classifier's performance using both precision and recall. Using the arithmetic mean (0.9 + 0.1) / 2 = 0.5 would suggest a decent model even when recall is disastrously low. The harmonic mean gives 2 × 0.9 × 0.1 / (0.9 + 0.1) = 0.18 — correctly revealing the problem. The harmonic mean penalizes imbalance between the two metrics far more aggressively than the arithmetic mean.
When you invest equal dollar amounts in multiple stocks, you buy more shares of cheaper (low P/E) stocks and fewer shares of expensive (high P/E) ones. The harmonic mean reflects this correctly: it weights each P/E by the inverse of its value, matching how dollars actually buy shares. The arithmetic mean overstates the typical valuation because it treats each stock as contributing equally regardless of how many shares your money bought.
For parallel resistors, the reciprocal rule 1/Req = Σ(1/Rᵢ) rearranges to Req = n / Σ(1/Rᵢ) — which is exactly the harmonic mean formula divided by n. So Req = HM(R₁, …, Rₙ) / n. For two resistors: Req = HM/2 = R₁R₂/(R₁+R₂). The same mathematics applies to series capacitors and lenses because they all obey reciprocal addition rules.
The effective population size Nₑ — the size of an idealized population with the same genetic drift as the real one — is the harmonic mean of census population sizes across generations. This correctly accounts for bottlenecks: a single generation with very few individuals restricts genetic diversity for all future generations, and the harmonic mean heavily weights that small value.
Main advantages: (1) Gives the mathematically correct average for rates with a fixed denominator. (2) Uses every value in the dataset. (3) Resistant to inflated high values. (4) Uniquely defined — no ambiguity. (5) Algebraically tractable, obeying AM × HM = GM². (6) Extends naturally to weighted and grouped data.
Main disadvantages: (1) Cannot be computed with any zero values. (2) Sensitive to small values in ways that can distort results if those small values are measurement errors. (3) Less intuitive than the arithmetic mean. (4) Requires confirming that your situation actually has a fixed denominator — misapplied, it gives wrong answers. (5) Cannot be calculated if any value is unknown.
Beyond the zero-value and negative-value restrictions, the harmonic mean's main limitation is scope: it is correct only for rates with a fixed denominator. Applied to any other kind of data it produces systematically incorrect results. It also does not handle missing values — you need every observation to compute it.
A harmonic progression is a sequence of numbers whose reciprocals form an arithmetic progression. If a, a+d, a+2d, … is an AP, then 1/a, 1/(a+d), 1/(a+2d), … is an HP. Any term in an HP is the harmonic mean of its two neighbors. The harmonic progression and the harmonic mean are related through reciprocals but serve different mathematical purposes.
The harmonic series is 1 + 1/2 + 1/3 + 1/4 + 1/5 + … — the sum of reciprocals of all positive integers. Despite the terms approaching zero, the sum grows without bound (the series diverges). This was first proved by Nicole Oresme in the 14th century. The series shares its name with the harmonic mean and harmonic progressions through the common theme of reciprocals.
Key Takeaways
HM = n / Σ(1/xᵢ). Divide the count by the sum of reciprocals. For two numbers a and b, the shortcut is 2ab/(a+b).
HM ≤ GM ≤ AM for all positive values. Equality holds only when all values are identical.
Use the harmonic mean when averaging a rate and the denominator of that rate stays fixed across all observations.
Equal time intervals → arithmetic mean is correct. Equal distances → harmonic mean is correct.
The F1 score in machine learning is the harmonic mean of precision and recall. It collapses toward the weaker metric, exposing models with poor recall or poor precision.
Averaging P/E ratios with equal dollar investment requires the harmonic mean. Averaging by market cap weight requires the weighted harmonic mean.
AM × HM = GM² — an exact identity for two positive numbers, not an approximation.
For grouped data: HM = Σf / Σ(f/X) for discrete distributions; use the class midpoint X̄ for continuous distributions.
The effective population size in genetics is the harmonic mean of census sizes across generations — bottleneck years dominate because small values have large reciprocals.
The harmonic mean is undefined for any dataset containing zeros or negative values. This is a hard mathematical constraint, not a software quirk.
Excel: =HARMEAN(range). Python: statistics.harmonic_mean(data) or scipy.stats.hmean(data). R: length(data) / sum(1/data).
A harmonic progression is a separate concept: a sequence whose reciprocals form an arithmetic progression. Any term in an HP is the harmonic mean of its neighbors.
Stuart, A. & Ord, J.K. — Kendall's Advanced Theory of Statistics (Vol. 1) | Bullen, P.S. — Handbook of Means and Their Inequalities | Python docs: statistics.harmonic_mean | For related concepts: measures of central tendency, geometric mean, weighted mean.