Calcoid
Math

Harmonic Mean Calculator

Compute the harmonic mean of positive numbers and compare it to the arithmetic and geometric mean. Built for averaging rates like MPG, speeds over fixed distance, and F1 scores.

Enter positive numbers

Only positive numbers. Use rates like MPG, speeds, or P/E ratios: the harmonic mean weights small values more heavily than the arithmetic mean does.

Common use cases

  • Average miles per gallon: Two cars at 30 and 60 MPG averaged over the same distance have a fleet MPG of 40, not 45. Harmonic mean is the correct average for rates measured over a shared denominator.
  • F1 score in classification: F1 is the harmonic mean of precision and recall. It punishes a model that scores high on one and low on the other, which is exactly what you want for imbalanced data.
  • Average speed over a fixed distance: Drive one mile at 30 mph and the next at 60 mph and your average speed is 40 mph, not 45. The harmonic mean shows up any time you are averaging speeds over equal distances.

Harmonic mean

40

From 2 values.

Count

2

Sum

90

Min

30

Max

60

AM, GM, HM (must satisfy AM >= GM >= HM)

Arithmetic

45

sum / n

Geometric

42.43

(prod)^(1/n)

Harmonic

40

n / sum(1/x)

For any set of positive numbers, HM <= GM <= AM. The harmonic mean weights smaller values more heavily, which is why it sits lowest.

Frequently Asked Questions about the Harmonic Mean Calculator

What is the harmonic mean?
The harmonic mean of n positive numbers is n divided by the sum of their reciprocals: HM = n / (1/x1 + 1/x2 + ... + 1/xn). It is the reciprocal of the arithmetic mean of the reciprocals, and it is the right average whenever the underlying quantity is a rate measured over a shared denominator.
When should I use the harmonic mean instead of the arithmetic mean?
Use it for rates and ratios with a fixed denominator. Common cases: averaging miles per gallon across a fleet that drove the same distance, averaging speeds over equal stretches of road, computing the F1 score from precision and recall, and combining harmonic intervals in music. If you average those with the arithmetic mean you systematically overstate the result.
Worked example: two cars at 30 and 60 MPG, why is the average 40 and not 45?
Drive each car 60 miles. The 30 MPG car burns 2 gallons; the 60 MPG car burns 1 gallon. Together that is 120 miles on 3 gallons, which is 40 MPG. The harmonic mean of 30 and 60 is 2 / (1/30 + 1/60) = 2 / (3/60) = 40. The arithmetic mean (45) would only be right if both cars used the same amount of fuel rather than drove the same distance.
What is the relationship to the arithmetic and geometric means?
For any list of positive numbers, HM <= GM <= AM. The three are equal only when every value is the same. The bigger the spread between the values, the bigger the gap between the three means. The calculator shows all three so you can see the gap at a glance, which itself is a useful signal of how dispersed your data is.
Why can't I use zero or negative numbers?
The formula divides by each value (1/x), so a zero is an undefined division. Negative values make the math return technically defined numbers, but they break the rate-averaging logic the harmonic mean is designed for: you cannot drive a fixed distance at -30 mph. The calculator rejects non-positive inputs to keep the result meaningful.