ToolNimba

๐ŸŽต Harmonic Mean Calculator - Average of Rates, Speeds and Ratios

Shihab Mia By Shihab Mia ยท Updated 2026-07-25

Harmonic mean
-
Geometric mean
-
Arithmetic mean
-
Count (n)
-
Sum of reciprocals
-
Product of values
-

The harmonic mean is the average to use when your numbers are rates, ratios or "per something" quantities: speeds, prices per unit, price-to-earnings ratios, or precision and recall scores. Enter a list of positive numbers below and this calculator returns the harmonic mean using HM = n / sum(1/x), the reciprocal of the average of the reciprocals, and shows the geometric and arithmetic means alongside it for comparison. For two numbers there is a shortcut, HM = 2ab / (a + b), and it also equals the geometric mean squared divided by the arithmetic mean (HM = GM^2 / AM). Everything is calculated instantly in your browser, and nothing you type is sent anywhere.

What is the Harmonic Mean Calculator?

The harmonic mean is one of the three classical Pythagorean means, alongside the arithmetic mean (the plain average you already know) and the geometric mean. You find it by taking the reciprocal of each value, averaging those reciprocals, and then taking the reciprocal of that result. Written as a formula it is HM = n / (1/x1 + 1/x2 + ... + 1/xn), where n is how many numbers you have. Because it relies on reciprocals, every value must be greater than zero; a single zero would make a reciprocal infinite and break the calculation, and negative values make the result meaningless as an average of rates.

The reason it matters is that it gives the correct answer when you average rates over a fixed base. The classic case is average speed: if you drive a fixed distance at 40 km/h and the same distance back at 60 km/h, your average speed for the whole trip is the harmonic mean (48 km/h), not the arithmetic mean (50 km/h). You spent more time at the slower speed, so the slow leg pulls the true average down. The same logic applies to averaging price-to-earnings (P/E) ratios across a set of stocks, computing the F1 score in machine learning (the harmonic mean of precision and recall), and combining resistors wired in parallel.

For small sets there are shortcuts worth knowing. For two numbers a and b, HM = 2ab / (a + b). For three numbers a, b and c, HM = 3abc / (ab + bc + ca). And for exactly two positive numbers, the harmonic mean has a neat relationship to the other two means: HM = GM^2 / AM, the geometric mean squared divided by the arithmetic mean. This calculator applies the general n-value formula to whatever list you enter, so these shortcuts are useful mainly for checking a two- or three-number answer by hand.

Some situations call for a weighted harmonic mean, where each value carries a different weight instead of counting equally. The formula becomes HM_weighted = (sum of weights) / (sum of weight_i / x_i). This is the standard way analysts aggregate P/E ratios across a portfolio: each stock's P/E is weighted by its price or market value rather than treated as one equal data point, because a plain unweighted average would let a single small holding distort the result. This calculator computes the unweighted harmonic mean of the numbers you enter; the worked example below shows how to apply the weighted version by hand when your values are not all equally important.

Beyond speed and finance, the harmonic mean shows up wherever quantities combine through reciprocals. Resistors wired in parallel combine as 1/Rtotal = 1/R1 + 1/R2 + ... + 1/Rn, which is exactly the harmonic-mean pattern scaled by n. Capacitors in series follow the same reciprocal-sum rule. It appears in geometry problems involving parallel sides of a trapezoid and the classic "crossed ladders" problem, in computer science when averaging throughput rates or frames per second across runs, and in population genetics when estimating effective population size across generations with unequal numbers of breeding individuals.

For any set of positive numbers that are not all identical, the three means always line up in the same order: harmonic mean is the smallest, geometric mean sits in the middle, and arithmetic mean is the largest (HM <= GM <= AM). They are equal only when every number in the set is the same. The harmonic mean is pulled hardest toward the smallest values in your data, which is exactly why it resists being skewed upward by a few large outliers and why it suits rates where small values represent slow or expensive cases that deserve more weight.

When to use it

  • Finding true average speed when equal distances are covered at different speeds.
  • Averaging rates such as price per litre, cost per unit, or items produced per hour.
  • Computing the F1 score in data science, the harmonic mean of precision and recall.
  • Averaging financial multiples like price-to-earnings ratios across a portfolio of stocks.
  • Combining values in parallel, for example the total resistance of resistors wired in parallel or capacitors in series.
  • Averaging throughput or transfer rates in computer science, such as average download speed across several files of the same size.

How to use the Harmonic Mean Calculator

  1. Type or paste your positive numbers, separated by commas, spaces, or new lines.
  2. Make sure every value is greater than zero; the harmonic mean is undefined for zero or negative numbers.
  3. Read off the harmonic mean in the highlighted box.
  4. Compare it with the geometric and arithmetic means shown alongside to see how skewed your data is.
  5. For a weighted harmonic mean (unequal weights), use the formula and worked example below instead of this equal-weight calculator.

Formula & method

General: HM = n / (1/x1 + 1/x2 + ... + 1/xn), where n is the count of values and each x must be greater than 0. Two numbers: HM = 2ab / (a + b), which for two positive numbers also equals HM = GM^2 / AM. Three numbers: HM = 3abc / (ab + bc + ca). Weighted: HM_weighted = (w1 + w2 + ... + wn) / (w1/x1 + w2/x2 + ... + wn/xn).
How the Harmonic Mean WorksValuesx1, x2, ... xnReciprocals1/x1, 1/x2 ...Sum themsum(1/x)Divide n by itHM = n / sumExample: 40 km/h and 60 km/h (equal distances)Harmonic mean48Geometric mean48.99Arithmetic mean50HM ≤ GM ≤ AM, always, for positive numbersTwo-number shortcut: HM = 2ab / (a + b)Weighted: HM = (sum of weights) / (sum of weight/value)

Worked examples

Find the harmonic mean of 1, 2 and 4.

  1. n = 3
  2. Sum of reciprocals = 1/1 + 1/2 + 1/4 = 1 + 0.5 + 0.25 = 1.75
  3. HM = n / sum = 3 / 1.75 = 1.714286
  4. For comparison: arithmetic mean = (1 + 2 + 4) / 3 = 2.333333
  5. Geometric mean = (1 x 2 x 4)^(1/3) = 8^(1/3) = 2

Result: Harmonic mean โ‰ˆ 1.714286 (note HM < GM < AM: 1.714 < 2 < 2.333)

A car covers equal distances at 40 km/h and 60 km/h. What is its average speed?

  1. Use the two-number shortcut HM = 2ab / (a + b)
  2. HM = (2 x 40 x 60) / (40 + 60)
  3. HM = 4800 / 100 = 48
  4. The arithmetic mean would be (40 + 60) / 2 = 50, which is too high

Result: Average speed = 48 km/h, lower than the naive 50 km/h because more time is spent at 40 km/h

A portfolio holds three stocks weighted by how much of the portfolio value each represents: 50% at a P/E of 10, 30% at a P/E of 20, and 20% at a P/E of 40. Find the portfolio-level P/E using the weighted harmonic mean.

  1. Weighted harmonic mean = (sum of weights) / (sum of weight_i / x_i)
  2. Sum of weights = 0.50 + 0.30 + 0.20 = 1.00
  3. Sum of weight_i / x_i = 0.50/10 + 0.30/20 + 0.20/40 = 0.05 + 0.015 + 0.005 = 0.07
  4. HM_weighted = 1.00 / 0.07 = 14.29
  5. For comparison, the weighted arithmetic mean would be 0.50(10) + 0.30(20) + 0.20(40) = 19, noticeably higher

Result: Weighted portfolio P/E โ‰ˆ 14.29, versus 19 with a weighted arithmetic mean; the harmonic mean is the standard method here because P/E mixes price and earnings, and it keeps a few high-P/E holdings from overstating the group figure

The three Pythagorean means compared on the same data sets

Data setHarmonic meanGeometric meanArithmetic mean
2, 83.245
1, 2, 41.71428622.333333
40, 604848.989850
3, 4, 644.16024.3333
5, 5, 5555

When to reach for each mean

MeanBest forExample
HarmonicRates over a fixed baseAverage speed, price per unit, F1 score
GeometricGrowth rates and ratiosAverage annual return, index numbers
ArithmeticAdditive quantitiesTest scores, heights, ordinary totals

Harmonic mean formulas at a glance

SituationFormula
Two numbersHM = 2ab / (a + b)
Three numbersHM = 3abc / (ab + bc + ca)
Any n numbersHM = n / (1/x1 + 1/x2 + ... + 1/xn)
Weighted (n numbers)HM = (sum of weights) / (sum of weight_i / xi)
Two numbers, via GM and AMHM = GM^2 / AM

Common mistakes to avoid

  • Using the plain (arithmetic) average for rates. Averaging two speeds over equal distances with the arithmetic mean overstates the result. Equal distances mean more time is spent at the slower speed, so the harmonic mean is the correct figure.
  • Including zero or negative values. The harmonic mean depends on reciprocals, so a value of 0 makes 1/0 undefined and negatives produce meaningless results. This tool only accepts numbers greater than zero.
  • Confusing the harmonic mean with the geometric mean. They are different means. The harmonic mean averages reciprocals, the geometric mean multiplies values and takes the nth root. For the same positive data the harmonic mean is always the smaller of the two.
  • Forgetting the fixed-base condition for average speed. The harmonic mean gives average speed only when the distances are equal. If equal times are spent at each speed instead, the arithmetic mean of the speeds is the correct average.
  • Ignoring weights when values represent unequal groups. If your values do not all carry the same importance, such as P/E ratios across differently sized stock holdings, a plain harmonic mean treats them as equal and can mislead. Use the weighted harmonic mean formula instead, weighting each value by its share of the total.
  • Assuming any two-mean shortcut works for large lists. The two-number and three-number shortcuts (HM = 2ab/(a+b) and HM = 3abc/(ab+bc+ca)) only apply to exactly two or three values. For longer lists, use the general formula HM = n / sum(1/x), which is what this calculator applies automatically.

Glossary

Harmonic mean
The reciprocal of the average of the reciprocals: n divided by the sum of 1/x. Best for averaging rates.
Weighted harmonic mean
A harmonic mean where each value is weighted by its share of the total, calculated as (sum of weights) divided by (sum of weight/value). Used for portfolio-level P/E ratios and similar aggregations.
Reciprocal
One divided by a number. The reciprocal of x is 1/x, so the reciprocal of 4 is 0.25.
Arithmetic mean
The ordinary average: add the values and divide by how many there are.
Geometric mean
The nth root of the product of n values, used for growth rates and ratios.
Pythagorean means
The trio of classical means (arithmetic, geometric, harmonic) that always satisfy HM <= GM <= AM.
P/E ratio
Price-to-earnings ratio, a stock valuation figure equal to share price divided by earnings per share; commonly averaged across a portfolio using the weighted harmonic mean.
F1 score
A machine learning metric equal to the harmonic mean of precision and recall, used because it penalizes a low value in either one.

Frequently asked questions

What is the harmonic mean?

The harmonic mean is an average defined as n divided by the sum of the reciprocals of your values: HM = n / (1/x1 + 1/x2 + ... + 1/xn). It is the most appropriate average for rates and ratios, because it weights smaller values more heavily than the ordinary arithmetic mean does.

When should I use the harmonic mean instead of the average?

Use the harmonic mean when your numbers are rates measured over a fixed base, such as speeds over equal distances, price per unit, or items per hour. In those situations the plain arithmetic mean overstates the true average, while the harmonic mean gives the correct result.

How do I calculate the harmonic mean of two numbers?

For two values a and b there is a simple shortcut: HM = 2ab / (a + b). For example, the harmonic mean of 40 and 60 is (2 x 40 x 60) / (40 + 60) = 4800 / 100 = 48. This is the same answer the full reciprocal formula gives.

How do I calculate the harmonic mean of three numbers?

For three values a, b and c, use HM = 3abc / (ab + bc + ca). For example, the harmonic mean of 3, 4 and 6 is (3 x 3 x 4 x 6) / (3x4 + 4x6 + 6x3) = 216 / 54 = 4, matching the general formula.

What is a weighted harmonic mean and when do I need it?

A weighted harmonic mean gives each value a different level of importance instead of counting every value equally: HM_weighted = (sum of weights) / (sum of weight/value). It is used most often to average price-to-earnings ratios across a stock portfolio, where each holding is weighted by its price or market value rather than treated as one equal data point.

Why can the harmonic mean not handle zero or negative numbers?

The formula divides by each value through its reciprocal, so a value of zero gives 1/0, which is undefined, and negative values make the result lose its meaning as an average of rates. For that reason this calculator only accepts numbers greater than zero.

Is the harmonic mean always smaller than the arithmetic mean?

Yes, for any set of positive numbers that are not all identical the harmonic mean is the smallest of the three Pythagorean means, the geometric mean is in the middle, and the arithmetic mean is the largest (HM <= GM <= AM). The three are equal only when every value in the set is the same.

How is the harmonic mean used in the F1 score?

In machine learning the F1 score is the harmonic mean of precision and recall: F1 = 2 x (precision x recall) / (precision + recall). The harmonic mean is used because it punishes a low value in either metric, so a model only scores well if both precision and recall are reasonably high.

Why is the harmonic mean used to average P/E ratios instead of the arithmetic mean?

A P/E ratio mixes a price (numerator) with earnings (denominator), and averaging ratios like that with an arithmetic mean overweights stocks with unusually high P/E values. The harmonic mean, applied with each holding weighted by its size, correctly reflects total price paid per total earnings across the group.

What is the harmonic mean used for besides speed and averages?

It applies wherever quantities combine through reciprocals: resistors wired in parallel, capacitors in series, aggregating P/E ratios in finance, computing the F1 score in machine learning, and estimating effective population size in population genetics.