What Is the Harmonic Mean?
The Harmonic Mean (H) is one of the three classical Pythagorean averages alongside the Arithmetic Mean and Geometric Mean. Defined strictly as the reciprocal of the arithmetic mean of reciprocals (N ÷ Σ(1/xᵢ)), it is the only mathematically valid average whenever you combine rates, speeds, valuation ratios, or efficiency metrics sharing a common fixed numerator (such as miles, dollars invested, unit tasks, or test positives).
Suppose you drive 120 miles uphill at 40 mph and drive the exact same 120 miles downhill back home at 60 mph. Your arithmetic average (60 + 40) ÷ 2 = 50 mph is wrong because you spent 3 hours driving slow and only 2 hours driving fast! Harmonic Mean automatically weights time spent in inverse proportion to speed, delivering the exact round-trip speed of 48 mph. Our calculator solves unweighted Harmonic Mean, equal-distance average speed, parallel resistor/pipe combinations (R_eq = H ÷ N), Contraharmonic Mean, and Weighted Harmonic Mean for portfolio valuation multiples and variable-distance trips.
Harmonic Mean Formulas & Parallel Combinations
For any set of strictly positive measurements x₁, x₂, …, xₙ > 0 and optional weights wᵢ ≥ 0, apply these exact expressions:
Two-Value Shortcut (F1 Score): H = ( 2 × a × b ) ÷ ( a + b )
Weighted Harmonic Mean: H_w = ( Σ wᵢ ) ÷ ( Σ wᵢ / xᵢ )
Parallel Branch Equivalent: R_eq = 1 ÷ Σ( 1/xᵢ ) = H ÷ N
Contraharmonic Mean (CM): CM = Σ( xᵢ² ) ÷ Σ( xᵢ ) [where (HM + CM)/2 = AM for N = 2]
Arithmetic vs. Geometric vs. Harmonic Mean: Which Rate Rule Fits?
Choosing between the three Pythagorean averages comes down to checking which variable stays constant across your measurements:
| Scenario | What Is Held Fixed? | Correct Average | Quick Verification Example |
|---|---|---|---|
| Equal-Time Travel | Same hours spent per leg (denominator) | Arithmetic Mean (AM) |
1 hr @ 60 + 1 hr @ 40 = 50 mph |
| Equal-Distance Travel | Same miles per leg (numerator) | Harmonic Mean (HM) |
120 mi @ 60 + 120 mi @ 40 = 48 mph |
| Multi-Year Growth | Sequential compounding periods | Geometric Mean (GM) |
+50% then −50% = −13.40% CAGR |
| Dollar-Cost Investing | Same dollar amount bought each month | Harmonic Mean (HM) |
$100 @ $10 + $100 @ $20 = $13.33 avg cost/share |
Notice that Dollar-Cost Averaging (buying $100 of shares every month regardless of share price) works for the exact same mathematical reason: fixing dollars spent (the numerator) means you automatically buy twice as many shares when the price halves, pulling your true average cost per share down to the Harmonic Mean ($13.33) rather than the Arithmetic average price ($15.00)!
2 Worked Examples
Example 1: Computing Harmonic Mean, Parallel Flow & Contraharmonic Reflection (60 and 40)
Find the Harmonic Mean, Parallel Equivalent, and Contraharmonic Mean of 60 and 40:
- Sum the reciprocals:
1/60 + 1/40 = 2/120 + 3/120 = 5/120 ≈ 0.041667. - Divide count
N = 2by reciprocal sum:H = 2 ÷ (5/120) = 240 ÷ 5 = 48.0. Equivalently, use the two-number shortcut(2 × 60 × 40) ÷ (60 + 40) = 4,800 ÷ 100 = 48.0! - Compute Parallel Equivalent (
H ÷ N): Two60 Ωand40 Ωparallel resistors combine to48 ÷ 2 = 24 Ω(note24 < 40, strictly smaller than the smallest branch). - Compare the full Pythagorean + Contraharmonic Ladder:
HM = 48.0,GM = √2400 = 48.9898,AM = 50.0, andContraharmonic CM = (60² + 40²) ÷ (60 + 40) = 5,200 ÷ 100 = 52.0. Observe thatAM (50)sits exactly halfway betweenHM (48)andCM (52)!
Example 2: Portfolio Weighted P/E Ratio & Machine Learning F1-Score
Suppose an ETF allocates 70% of capital to Value Stocks trading at a Price-to-Earnings ratio of P/E = 15 and 30% to Growth Stocks trading at P/E = 30. Use Mode 3 (Weighted Harmonic Mean with 15:70, 30:30) to compute the true aggregate portfolio P/E:
- Why Arithmetic Fails: Computing
0.70(15) + 0.30(30) = 19.50xaverages the denominators illegally, overstating valuation! - Compute earnings per $100 invested: The $70 slice earns
$70 ÷ 15 = $4.6667, and the $30 slice earns$30 ÷ 30 = $1.0000, giving Total Earnings = $5.6667 on $100 Market Value. - Apply Weighted Harmonic Mean:
H_w = (70 + 30) ÷ (70/15 + 30/30) = 100 ÷ 5.6667 = 17.6471x, nearly two P/E points lower than the inflated arithmetic number! - Bonus ML F1-Score Check: A fraud classifier achieving
Precision = 0.90andRecall = 0.60yieldsF1 = (2 × 0.90 × 0.60) ÷ (0.90 + 0.60) = 1.08 ÷ 1.50 = 0.720(72.0%) in Mode 1.
Parallel Resistors, Pipes & Contraharmonic Reflection
In electrical engineering and fluid dynamics, parallel paths add conductances (1/R_eq = 1/R₁ + 1/R₂ + … + 1/Rₙ) rather than resistances. Because Harmonic Mean equals N ÷ Σ(1/Rᵢ), the combined parallel equivalent R_eq is always simply Harmonic Mean ÷ N! For three pipes taking 2, 3, and 6 hours individually to fill a tank, HM = 3 hours and all three working together fill the tank in 3 ÷ 3 = 1.0 hour.
Why Harmonic Mean Is Sensitive to Very Small Values (and Rejects Zero)
Notice how arithmetic mean is pulled skyward by extreme high outliers (one billionaire skews mean income), whereas Harmonic Mean flips that sensitivity completely: because reciprocals 1/x blow up as x gets tiny, Harmonic Mean is heavily anchored by the smallest values while ignoring huge upper spikes! Consider adding a huge 1000 outlier to [2, 4]: Arithmetic jumps to 335.3, while Harmonic moves barely at all from 2.67 to 3.99 (just +1.3!). Conversely, if any value approaches 0, 1/x -> ∞ collapses the Harmonic Mean straight toward 0.
Generalized Power Mean (M_p) & Weighted F_β Classification
In higher mathematics, all Pythagorean averages belong to a single continuous spectrum called the Hölder Generalized Power Mean: M_p = ( (1/N) × Σ xᵢ^p )^(1/p). Setting exponent p = 1 produces the Arithmetic Mean, taking the limit p -> 0 yields the Geometric Mean, setting p = −1 delivers the Harmonic Mean, and setting p = 2 yields Root Mean Square (RMS). Because Power Mean rises monotonically with p, the inequality HM (p=−1) ≤ GM (p=0) ≤ AM (p=1) ≤ RMS (p=2) holds universally!
In information retrieval and clinical AI evaluation, weighting Recall β times as heavily as Precision transforms F1 directly into the Weighted Harmonic Mean F_β: F_β = (1 + β²) × (Precision × Recall) ÷ (β² × Precision + Recall), matching weighted-hm inputs with weight 1 on Precision and weight β² on Recall! For example, with Precision = 0.90 and Recall = 0.60, a precision-first search model (F_0.5, weights 1 : 0.25) scores 0.8182, whereas a safety-critical medical detector prioritizing recall (F_2, weights 1 : 4) scores 0.6429, pulling sharply toward the lower Recall score.
Harmonic Mean Formulas in Excel, Google Sheets & Python
Enter positive rates inside cell range A2:A10 and run:
Excel (Weighted HM: values A2:A5, weights B2:B5): =SUM(B2:B5) / SUMPRODUCT(B2:B5, 1/A2:A5)
Python (Standard Library 3.6+): import statistics; statistics.harmonic_mean(data)
Python (Weighted HM 3.10+): statistics.harmonic_mean(data, weights=w)
Python (SciPy): from scipy.stats import hmean; hmean(data)
5 Common Harmonic Mean Mistakes to Avoid
- Using Harmonic Mean When Equal Time (Not Equal Distance) Was Driven: If you drive 1 hour at
60 mphand 1 hour at40 mph, total distance is 100 miles in 2 hours (50 mphArithmetic Mean!). Only use Harmonic Mean when distance per leg is equal, or feed actual leg distances as weights into Mode 3. - Including
0in the Dataset: Zero makes1/0mathematically undefined. In machine learning F1-score, if Precision or Recall equals0, conventions defineF1 = 0directly by limit. - Forgetting to Divide by
Nfor Parallel Resistors/Pipes: The Harmonic Mean of[6, 6]is6, whereas two6 Ωresistors in parallel yieldR_eq = 6 ÷ 2 = 3 Ω(shown as Parallel Eq in Mode 2!). - Mixing Positive and Negative Returns Into Harmonic Mean: Unlike Mode 2 of our Geometric Mean Calculator, raw negative ratios destroy reciprocal meaning. Keep inputs strictly positive (
xᵢ > 0). - Averaging Valuation Multiples With Arithmetic Weights: Always weight P/E or Price-to-Sales multiples by Earnings/Revenue share, or apply Weighted Harmonic Mean to portfolio value weights!
Related Means & Spread Calculators
Compare every average and dispersion metric side by side inside our Math & Statistics hub:
- Mean Calculator: compute Arithmetic, Geometric, and Harmonic means together.
- Geometric Mean Calculator: compound returns (CAGR), log-sum calculations, and AM ≥ GM ≥ HM visual comparisons.
- Weighted Average Calculator: dynamic row-based weighted arithmetic means and target score solver.
- Coefficient of Variation (CV) Calculator & Range Calculator: measure relative volatility and endpoint spread.
Review Staticnexa's formula testing and precision standards in our Editorial & Mathematical Accuracy Policy.
Frequently Asked Questions
What is the formula for Harmonic Mean?
Harmonic Mean equals the count of observations N divided by the sum of their reciprocals: H = N / (1/x1 + 1/x2 + ... + 1/xN). For two positive numbers a and b, it simplifies cleanly to 2ab / (a + b).
When should you use Harmonic Mean instead of Arithmetic Mean?
Use Harmonic Mean whenever averaging rates, speeds, or ratios that share the same numerator unit, such as round-trip speeds over equal distances, parallel branch work rates, Dollar-Cost Averaging per share, F1-score, and weighted P/E valuation multiples.
Why is Harmonic Mean always the smallest of the three Pythagorean means?
Because taking reciprocals magnifies tiny numbers (1/x grows large as x shrinks), small values exert far more downward pull on Harmonic Mean than on Geometric or Arithmetic means. Thus HM <= GM <= AM holds for all positive numbers.
How does Harmonic Mean relate to parallel resistors or pipes?
Equivalent parallel combination equals 1 / Sum(1/R_i), which is identically equal to Harmonic Mean divided by the count of branches (R_eq = H / N). Our Speed & Parallel Rates mode reports both H and R_eq.
Can Harmonic Mean handle zero or negative numbers?
No. Because dividing 1 by 0 is undefined and opposite-sign reciprocals can cancel to 0, standard Harmonic Mean is strictly defined for positive datasets (x > 0).
What is the Contraharmonic Mean?
Contraharmonic Mean equals Sum(x_i^2) / Sum(x_i), leaning toward larger values in a dataset. For any two positive numbers, Arithmetic Mean sits exactly halfway between Harmonic Mean and Contraharmonic Mean: AM = (HM + CM) / 2.
Mathematical References & Standards
- Wikipedia: Harmonic Mean: Definition, Applications & Mean Relationships (Mathematical properties, equal-distance speed derivations, Dollar-Cost Averaging, and Weighted P/E ratios)
- Wolfram MathWorld: Harmonic Mean: Formula & Pythagorean Ordering (Formal reciprocal identity and relationship to Arithmetic and Geometric means)
- Wikipedia: F-Score (F1 Classification Metric) (Derivation of F1 = 2PR / (P + R) as the unweighted harmonic mean of Precision and Recall)
- Wikipedia: Contraharmonic Mean: Symmetry Around the Arithmetic Mean (Identity proving AM = (HM + CM) / 2 for two-element sets)
- NIST Engineering Statistics Handbook: Section 1.3.5.1: Measures of Location (Federal statistical guidance on location estimators and scale robustness)