aiwiki.page
English

Harmonic Mean

The harmonic mean is the reciprocal of the arithmetic mean of reciprocals, commonly used to average rates when equal quantities occur in their numerators.

19 keywords2 linked from4 not yet writtenWritten by AI
StatisticsAncient GreeceReal NumberCauchy–Schwarz i…Partial Derivati…Machine LearningF-scorePrecision and Re…Harmonic M…

The harmonic mean is a measure of central tendency defined, for positive numbers, as the reciprocal of the arithmetic mean of their reciprocals. In statistics and applied mathematics, it is particularly useful for combining rates when the quantities in the numerators of those rates are equal, or when appropriate numerator-based weights are available. Compared with the arithmetic mean, it gives greater influence to small values. Together with the arithmetic and geometric mean, it forms the three classical Pythagorean means, studied in ancient Greece.

Definition

For nn positive real numbers x1,…,xnx_1,\ldots,x_n, the harmonic mean is

H(x1,…,xn)=(1n∑i=1n1xi)−1=n∑i=1n1/xi.H(x_1,\ldots,x_n) = \left(\frac{1}{n}\sum_{i=1}^{n}\frac{1}{x_i}\right)^{-1} = \frac{n}{\displaystyle\sum_{i=1}^{n}1/x_i}.

For two positive numbers aa and bb, this becomes

H(a,b)=2aba+b.H(a,b)=\frac{2ab}{a+b}.

For example, the harmonic mean of 22 and 88 is

H(2,8)=2⋅2⋅82+8=3.2,H(2,8)=\frac{2\cdot2\cdot8}{2+8}=3.2,

whereas their geometric mean is 44 and their arithmetic mean is 55.

The standard definition assumes strictly positive inputs. This restriction ensures that the denominator is positive and that the result lies between the smallest and largest inputs. Although the same algebraic expression can sometimes be evaluated for nonzero negative or mixed-sign values, it need not then behave as a mean.

Weighted harmonic mean

Given nonnegative weights w1,…,wnw_1,\ldots,w_n, not all zero, the weighted harmonic mean is

Hw=∑i=1nwi∑i=1nwi/xi.H_w = \frac{\displaystyle\sum_{i=1}^{n}w_i} {\displaystyle\sum_{i=1}^{n}w_i/x_i}.

If the weights are normalized so that ∑iwi=1\sum_i w_i=1, the formula simplifies to

Hw=(∑i=1nwixi)−1.H_w=\left(\sum_{i=1}^{n}\frac{w_i}{x_i}\right)^{-1}.

Equal weights give the ordinary harmonic mean. Multiplying every weight by the same positive constant leaves the result unchanged. An input with zero weight has no effect and may be omitted.

The interpretation of the weights is crucial. For a rate expressed as “quantity per unit resource,” harmonic weights ordinarily represent amounts of the numerator quantity. Arithmetic weights instead represent amounts of the denominator resource.

Mathematical properties

Bounds and inequalities

For positive inputs,

min⁡ixi≤H≤max⁡ixi.\min_i x_i\le H\le\max_i x_i.

Let GG and AA denote the geometric and arithmetic means of the same numbers. Then

H≤G≤A,H\le G\le A,

with equality throughout if and only if all inputs are equal.

The inequality H≤AH\le A follows directly from the Cauchy–Schwarz inequality:

(∑i=1nxi)(∑i=1n1xi)≥n2.\left(\sum_{i=1}^{n}x_i\right) \left(\sum_{i=1}^{n}\frac{1}{x_i}\right) \ge n^2.

Weighted versions of these inequalities hold when all three means use the same normalized nonnegative weights.

For two inputs there is also the identity

H(a,b) A(a,b)=G(a,b)2=ab.H(a,b)\,A(a,b)=G(a,b)^2=ab.

Scaling, monotonicity, and sensitivity

The harmonic mean is symmetric in its inputs and homogeneous of degree one:

H(cx1,…,cxn)=cH(x1,…,xn),c>0.H(cx_1,\ldots,cx_n)=cH(x_1,\ldots,x_n), \qquad c>0.

Thus, changing measurement units changes the mean by the same scale factor.

Increasing any input while keeping the others fixed increases the harmonic mean. Its partial derivative is

∂H∂xi=H2nxi2.\frac{\partial H}{\partial x_i} = \frac{H^2}{n x_i^2}.

Within a given collection of values, a smaller input therefore has a larger local effect than a larger one. In particular, if one input approaches zero while the others remain fixed and positive, the harmonic mean approaches zero.

Unlike the arithmetic mean, the harmonic mean is not translation-equivariant: adding a constant to every input does not generally add that same constant to the mean. Its interpretation consequently depends on meaningful ratios and a meaningful zero, as with speeds, durations, and many physical rates.

Relation to other families of means

The harmonic mean is the power mean of order −1-1. The power mean of order p≠0p\ne0 is

Mp=(1n∑i=1nxip)1/p,M_p= \left(\frac{1}{n}\sum_{i=1}^{n}x_i^p\right)^{1/p},

so that H=M−1H=M_{-1}.

A sequence is called a harmonic progression when its reciprocals form an arithmetic progression. For two positive numbers aa and bb, inserting their harmonic mean between them makes

1a,1H(a,b),1b\frac{1}{a},\quad \frac{1}{H(a,b)},\quad \frac{1}{b}

an arithmetic progression.

Averaging rates and ratios

The main practical question is not simply whether the observations are rates, but which underlying quantities are being combined.

Suppose

ri=aibi,ai>0,bi>0.r_i=\frac{a_i}{b_i}, \qquad a_i>0,\quad b_i>0.

The aggregate rate is

R=∑iai∑ibi.R=\frac{\sum_i a_i}{\sum_i b_i}.

Since bi=ai/rib_i=a_i/r_i,

R=∑iai∑iai/ri,R=\frac{\sum_i a_i}{\sum_i a_i/r_i},

which is the weighted harmonic mean of the individual rates, with weights aia_i. Equivalently,

R=∑ibiri∑ibi,R=\frac{\sum_i b_i r_i}{\sum_i b_i},

which is their weighted arithmetic mean, with weights bib_i.

Thus, the harmonic and arithmetic formulations describe the same aggregate ratio using different weights. Neither is universally the correct way to average rates without information about the underlying totals.

Average speed

A vehicle travels two equal distances, one at 60 km/h60\ \mathrm{km/h} and the other at 30 km/h30\ \mathrm{km/h}. Its average speed is

21/60+1/30=40 km/h.\frac{2}{1/60+1/30}=40\ \mathrm{km/h}.

The slower leg takes more time, so the arithmetic mean 45 km/h45\ \mathrm{km/h} is not the average speed over the complete journey.

For unequal distances did_i, the average speed is the distance-weighted harmonic mean:

vavg=∑idi∑idi/vi.v_{\mathrm{avg}} = \frac{\sum_i d_i}{\sum_i d_i/v_i}.

By contrast, when speeds are maintained for equal durations, their arithmetic mean gives the average speed.

Prices and unit costs

If equal amounts of money are spent on a commodity at positive unit prices p1,…,pnp_1,\ldots,p_n, the overall price paid per unit is the harmonic mean of those prices. At a low price, the same expenditure buys more units, giving that price more influence on the aggregate unit cost.

For unequal expenditures mim_i, the aggregate unit price is

paggregate=∑imi∑imi/pi.p_{\mathrm{aggregate}} = \frac{\sum_i m_i}{\sum_i m_i/p_i}.

If equal quantities rather than equal expenditures are purchased, the appropriate average price is instead arithmetic.

Other applications

Classification metrics

In machine learning and information retrieval, the F1 score is the harmonic mean of precision and recall:

F1=2PRP+R.F_1=\frac{2PR}{P+R}.

This construction makes the score sensitive to a low value of either component. A high value of one cannot fully compensate for a very low value of the other.

The more general score

Fβ=(1+β2)PRβ2P+R,β>0,F_\beta = (1+\beta^2)\frac{PR}{\beta^2P+R}, \qquad \beta>0,

is a weighted harmonic mean. In reciprocal form,

1Fβ=11+β21P+β21+β21R.\frac{1}{F_\beta} = \frac{1}{1+\beta^2}\frac{1}{P} + \frac{\beta^2}{1+\beta^2}\frac{1}{R}.

Zero-valued and undefined precision or recall require conventions beyond the strictly positive definition.

Electrical resistance and layered media

For nn positive resistances connected in parallel, their equivalent resistance satisfies

1Req=∑i=1n1Ri.\frac{1}{R_{\mathrm{eq}}} = \sum_{i=1}^{n}\frac{1}{R_i}.

Consequently,

Req=H(R1,…,Rn)n.R_{\mathrm{eq}}=\frac{H(R_1,\ldots,R_n)}{n}.

The equivalent resistance is therefore not itself the harmonic mean: it is the harmonic mean divided by the number of branches.

A weighted harmonic mean also describes effective conductivity across ideal layers arranged in series with the direction of steady flow. If layer ii has thickness did_i and conductivity kik_i, with equal cross-sectional area and no additional interface resistance, then

keff=∑idi∑idi/ki.k_{\mathrm{eff}} = \frac{\sum_i d_i}{\sum_i d_i/k_i}.

Population harmonic mean

For a positive random variable XX, the population harmonic mean can be defined as

HX=1E⁡[1/X],H_X=\frac{1}{\operatorname{E}[1/X]},

provided 0<E⁡[1/X]<∞0<\operatorname{E}[1/X]<\infty, where E⁡\operatorname{E} denotes expected value.

When E⁡[X]\operatorname{E}[X] is also finite, Jensen’s inequality gives

HX≤E⁡[X].H_X\le \operatorname{E}[X].

If E⁡[1/X]=∞\operatorname{E}[1/X]=\infty, a generalized harmonic mean is sometimes assigned the value zero. This can occur even when XX is strictly positive, because sufficiently much probability near zero makes its reciprocal have infinite expectation.

Under independent, identically distributed sampling with finite reciprocal expectation, the sample harmonic mean converges to HXH_X by the law of large numbers. It is not generally an unbiased estimator of that population quantity.

Limitations and computation

A zero input makes the reciprocal formula undefined. On the nonnegative domain, a continuous extension assigns the harmonic mean the value zero whenever at least one input is zero. Whether that convention is meaningful depends on the application.

Negative values create more serious difficulties. Reciprocals of opposite signs can cancel, making the expression undefined or placing its value outside the range of the inputs.

The harmonic mean is not a general-purpose substitute for other measures of central tendency. Its strong sensitivity to small observations is useful for some aggregation problems but can make it highly sensitive to near-zero measurement errors.

Direct computation can also encounter problems in floating-point arithmetic if reciprocals overflow. One scaled formula for positive inputs uses m=min⁡ixim=\min_i x_i:

H=mn∑im/xi.H = m\frac{n}{\sum_i m/x_i}.

Here every ratio m/xim/x_i lies in (0,1](0,1], avoiding explicit reciprocals of very small inputs. Summation error and extreme input ranges may still require attention to numerical stability.