Harmonic Mean Calculator

Harmonic mean calculation

Enter the positive values

Separate values with commas, semicolons, spaces or new lines. In comma-decimal locales, use semicolons or new lines between decimal values.

Every value must be finite and greater than zero. Invalid, zero or negative values stop the calculation instead of being ignored.

Calculate the harmonic mean of up to 500 strictly positive values and compare it with their arithmetic mean. The harmonic mean is useful for rates and ratios when each observation has the same numerator or exposure, such as speeds over equal distances or prices paid with equal amounts of money. Every token must be valid and greater than zero. The calculator rejects the entire data set if it finds invalid, zero or negative input, so it never returns a plausible answer for a different set of values.

How to calculate a harmonic mean

  1. 1

    Enter positive values

    Enter up to 500 finite numbers separated by commas, semicolons, spaces or new lines. In comma-decimal locales, separate decimal values with semicolons or new lines.

  2. 2

    Check the complete data set

    The calculator stops on an invalid token, zero or negative value. In funnel mode, confirm the count, minimum and maximum before continuing.

  3. 3

    Sum the scaled reciprocals

    The calculation uses the equivalent reciprocal formula with numerical scaling to avoid unnecessary overflow or underflow.

  4. 4

    Compare the two means

    Read the localized harmonic mean beside the arithmetic mean and the number of values used.

Definition and formula

For positive values x₁, x₂, …, xₙ, the harmonic mean H is:

H = n / (1/x₁ + 1/x₂ + ... + 1/xₙ)

The formula divides the number of values by the sum of their reciprocals. It agrees with the definition published in the NIST Dataplot reference and the equal-weight form documented by SciPy.

This calculator accepts only strictly positive values. That domain keeps every reciprocal defined and matches the positive-rate use cases and the comparison of means described below.

Worked example: equal distances

Suppose a vehicle travels the same distance at 60 km/h and 30 km/h. The arithmetic mean of the two speeds is 45 km/h, but it is not the average speed for the whole trip because the slower leg takes more time.

H = 2 / (1/60 + 1/30)
  = 2 / 0.05
  = 40 km/h

The average speed over the two equal-distance legs is 40 km/h. If the vehicle instead spent the same amount of time at each speed, the arithmetic mean of 45 km/h would be appropriate.

Harmonic, geometric and arithmetic means

For the same set of strictly positive values, the harmonic mean is no greater than the geometric mean, and the geometric mean is no greater than the arithmetic mean. Equality occurs when all values are the same.

Data set Harmonic mean Geometric mean Arithmetic mean
1, 2, 4 1.714286 2 2.333333
30, 60 40 42.426407 45
5, 5, 5 5 5 5

The calculator displays the harmonic and arithmetic means. Use the related geometric mean calculator if you also need the middle value.

When the harmonic mean is appropriate

  • Speeds over equal distances: each speed applies to the same distance.
  • Prices with equal spending: each purchase uses the same amount of money, so the average cost per unit is harmonic.
  • Comparable rates with a common numerator: the reciprocal formulation reflects the shared exposure.
  • Precision and recall: the F1 score is a specialized harmonic mean of precision and recall, as documented by scikit-learn. Classification libraries define their own behavior when either quantity is zero; this general calculator instead requires positive inputs.

Do not choose the harmonic mean merely because the numbers are called rates. If observations have different distances, spending amounts or exposures, an unweighted harmonic mean can be misleading. Use an appropriately weighted calculation instead.

Input rules and numerical behavior

  • The data set can contain at most 500 values and 20,000 characters.
  • ASCII digits and the native digits used by the supported locales are accepted.
  • The active locale’s decimal mark is accepted. In a comma-decimal locale, write values such as 1,5; 2,5; 5 or put each value on a new line.
  • Grouping separators and scientific notation are not accepted because they can be ambiguous in a list.
  • Every token must be a finite number greater than zero. One invalid token stops the calculation and removes any stale result.
  • The computation scales both reciprocal and arithmetic sums before calculating the final means. This reduces avoidable floating-point overflow and underflow for very large or very small positive values.
  • Results use the active locale’s digits and separators. Extremely small or large values may use localized scientific notation.

Privacy and funnel storage

The calculation runs in this browser. Values and results are not bound to our servers and are not sent to the server. On the single-page calculator, the values stay in page memory.

Funnel mode stores the data set only in this tab’s session storage for up to 30 minutes so it can move between three pages. The fixed expiry is not extended when you continue. At most three current harmonic-mean jobs are retained, and only a random 32-character job identifier appears in the URL. Start over removes the current local record after confirmation. If tab storage is blocked, expired or damaged, the tool shows a recovery state rather than inventing a result.

Frequently Asked Questions

Use it when averaging positive rates or ratios with a shared numerator or equal exposure, such as speed over equal distances or unit prices from equal spending. Use the arithmetic mean for equal time intervals or ordinary additive measurements. If the exposures differ, use a suitable weighted calculation.

Silently discarding a token would calculate a different data set while still showing a plausible result. The calculator therefore rejects invalid, zero, negative and non-finite values and keeps the input visible for correction.

Not in this calculator. The reciprocal 1/0 is undefined, so the accepted domain is strictly positive. Some specialized definitions, including software metrics, set results involving zero by convention; use the rules of that specific metric rather than mixing the conventions.

Reciprocals give smaller positive observations more influence. For strictly positive values, the inequality of means guarantees that the harmonic mean is less than or equal to the geometric mean, which is less than or equal to the arithmetic mean. They are equal only when every value is identical.

On a comma-decimal locale, use the comma as the decimal mark and separate values with semicolons, spaces or new lines. For example, enter 1,5; 2,5; 5. A comma followed by a space also works as a list separator, but semicolons or separate lines are clearer.

Yes. It recognizes ASCII digits plus the native decimal digits used by the supported Arabic, Persian, Indic, Bengali, Thai and full-width input systems. The result is formatted with the active locale.

You can enter up to 500 values and 20,000 characters. The limit keeps validation and calculation responsive in the browser. Use a statistical package for larger data sets or weighted harmonic means.

No. Values and results stay in the browser. In funnel mode, the data set is stored only in this tab for up to 30 minutes, and the URL contains only an opaque random job identifier. Nothing is sent to our servers.

Related Tools

Tool available in other languages