AI Glossary / Statistics and probability / Beginner

Harmonic mean

Definition

The harmonic mean of positive numbers is the reciprocal of the arithmetic mean of their reciprocals. For n positive values x1, ..., xn, it equals n divided by the sum of 1/xi. It is useful for certain averages of rates and ratios, especially when equal amounts of the numerator quantity are accumulated at different rates. Its suitability depends on what is held constant; it is not the correct average for every collection of rates.

What it means

A rate combines two quantities, such as distance divided by time. To find an overall rate, the safest starting point is total distance divided by total time. When the same distance is traveled at each speed, slower portions take more time and therefore matter more to the overall speed.

The harmonic mean captures that relationship through reciprocals. A speed's reciprocal is time per unit distance, so averaging those reciprocals and inverting gives the combined speed for equal distances.

For positive inputs, the harmonic mean is no greater than the geometric mean, which is no greater than the arithmetic mean. The means coincide when all inputs are equal.

How it works

Calculate H = n/[sum_i (1/xi)]. For positive weights wi, the weighted version is H_w = sum_i wi/[sum_i (wi/xi)]. The weights must represent the aggregation appropriate to the question; they are not arbitrary decorations added to make an answer look representative.

For speeds, distance weights give total distance divided by total travel time. For equal time intervals, however, the ordinary arithmetic mean of speeds gives the overall speed. Similar reasoning applies to processing rates when equal job quantities are completed at different rates.

The basic reciprocal formula requires positive, nonzero values. Some applications define extensions at zero, but these require explicit conventions. Negative values and mixtures of signs can produce undefined or misleading results and fall outside the standard positive-rate interpretation.

Three practical examples

  • A logistics analyst calculates average speed across equal-distance route segments.
  • An operations manager combines processing rates for equal-sized batches handled sequentially.
  • A machine-learning evaluator uses the F1 score, the harmonic mean of precision and recall, to summarize their joint performance under a specified evaluation setup.

Think of it this way

Think of filling identical containers with taps that have different flow rates. A slow tap takes disproportionately long to finish its container. Averaging the rates directly would overlook that extra time. Converting each rate into time per container, averaging those times, and converting back gives the harmonic-mean rate for the sequential task.

Worked example

A vehicle travels 120 kilometers at 40 kilometers per hour and another 120 kilometers at 80 kilometers per hour. The two legs take 120/40 = 3 hours and 120/80 = 1.5 hours. Overall speed is 240/4.5 = 53.3333 kilometers per hour.

The harmonic mean agrees: 2/(1/40 + 1/80) = 53.3333. The arithmetic mean, 60, would be wrong for these equal distances. If the vehicle instead spends equal times at the two speeds, its overall speed is 60.

For unequal distances of 120 and 240 kilometers at the same respective speeds, the distance-weighted harmonic mean is 360/(120/40 + 240/80) = 60. The changed answer follows from the changed weights.

As a separate AI example, precision 0.8 and recall 0.5 give F1 = 2/(1/0.8 + 1/0.5) = 0.6154. Independent calculations confirm all results. The F1 calculation summarizes two metrics; it does not use the physical travel-time interpretation.

Illustrative case study

In a fictional document-processing service, a manager compares two sequential batch stages using an arithmetic average of their page-processing rates. A colleague reconstructs the actual page counts and elapsed times and finds that the slower stage occupies more of the work period.

The team reports total pages processed divided by total elapsed processing time and uses harmonic weighting only where the task quantities justify it. It also separates setup time and idle time rather than silently excluding them. For customer commitments, the team checks end-to-end completion time instead of assuming a stage-rate average describes the whole service. The scenario illustrates choosing a meaningful denominator, not a demonstrated efficiency improvement.

Common misconceptions and mistakes

“Use the harmonic mean for rates” is incomplete advice. Equal distances call for a harmonic mean of speeds; equal times call for an arithmetic mean. Averaging ratios without understanding their numerators and denominators can give the wrong answer even when the formula is calculated perfectly.

Small positive inputs have substantial influence because their reciprocals are large. That is a mathematical property, not automatic robustness to outliers. The harmonic mean is also not a compounding-growth average; multiplicative growth often calls for a geometric mean. Zero handling in F1 or software libraries should be checked rather than inferred from a reciprocal expression that divides by zero.

Business use

Before aggregating a rate, write down the total quantity of interest and the total exposure, time, or resource that belongs in its denominator. Derive the appropriate weighting from those totals. This makes the calculation explainable and helps reveal missing setup costs, unequal workloads, or incompatible units.

For AI metrics, the harmonic mean can emphasize weakness in either precision or recall, but F1 ignores true negatives and may not reflect business costs. Report the underlying metrics and evaluation population alongside the summary. A single mean should not conceal materially different tradeoffs between systems.

People also ask

Why is the harmonic mean lower than the arithmetic mean?

For positive unequal values, reciprocals give smaller values greater influence in the combined result.

Can the harmonic mean exceed the largest input?

Not for positive inputs and positive weights.

Is averaging two F1 scores the same as computing F1 from pooled predictions?

Generally no; averaging choices and denominators matter.

Check your understanding

Why is 60 incorrect for the two equal-distance legs?

Answer: The slower leg takes more time, so equal weighting of speeds does not match total distance divided by total time.

What weights apply to unequal-distance legs?

Answer: Their distances, when expressing overall speed as a weighted harmonic mean.

Related terms

  • Weighted average
  • Precision
  • Recall
  • arithmetic mean
  • geometric mean
  • rate
  • ratio
  • F1 score
  • aggregation bias

Learn next

Next, derive averages from totals for several rate problems. Then compare arithmetic, geometric, and harmonic means on the same positive values, and examine how different averaging schemes affect machine-learning evaluation metrics.

  • Machine learning

More in Statistics and probability

  • Hajek projection - The Hájek projection of a finite-variance statistic based on independent observations is its best mean-square approximation within the class of additive...
  • Half-normal distribution - The half-normal distribution describes the absolute value of a normally distributed variable centered at zero.
  • Hampel test - A Hampel test, commonly called the Hampel identifier, flags observations that lie unusually far from a median relative to a robust estimate of spread based...
  • Hartley's test - Hartley's test, also called the F-max test, tests whether several normally distributed populations have equal variances by comparing the largest sample...
  • Haseman - Elston regression - Haseman - Elston regression is a family of statistical-genetics methods connecting similarity in quantitative traits with genetic sharing between pairs of...
  • Hawthorne effect - The Hawthorne effect refers to a change in behavior or responses arising because people know they are being observed or studied.

Sources

Sources: SciPy, hmean documentation, https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.hmean.html; scikit-learn, f1_score documentation, https://scikit-learn.org/stable/modules/generated/sklearn.metrics.f1_score.html. Official documentation was opened and the weighted reciprocal formula and F1 relationship checked. All travel, weighting, and metric calculations and the fictional processing scenario are original.

Previous: Harmonic function Next: Harmonic mean estimator

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer