# Harmonic mean minimizes sum of squared relative errors

I am looking for a reference where it is proven that the harmonic mean

$$\bar{x}^h = \frac{n}{\sum_{i=1}^n \frac{1}{x_i}}$$

minimizes ( in $z$) the sum of squared relative errors

$$\sum_{i=1}^n \left( \frac{(x_i - z)^2}{x_i}\right).$$

Why do you need a reference? This is a simple calculus problem: For the problem as you have formulated it to make sense, we must assume that all $x_i > 0$. Then define the function $$f(z) = \sum_{i=1}^n \frac{(x_i - z)^2}{x_i}$$ Then calculate the derivative with respect to $z$: $$f'(z) = -2\cdot \sum_{i=1}^n (1-\frac{z}{x_i})$$ then solving the equation $f'(z)=0$ gives the solution. Now, of course we must check that this is indeed a minimum, for that calculate the second derivative: $$f''(z) = -2 \cdot \sum_{i=1}^n (0-\frac1{x_i}) = 2 \sum_{i=1}^n \frac1{x_i} > 0$$ for the last inequality we used, finally, that all $x_i>0$. Without that assumption we could indeed risk that we had found a maximum!

As for a reference, maybe https://en.wikipedia.org/wiki/Fr%C3%A9chet_mean or https://en.wikipedia.org/wiki/Harmonic_mean or references therein.

• Thanks for your answer. A reference would save me some space. I want to cite the result as a Lemma into another proofs without having to include a self-contained proof of the Lemma. – Martin Van der Linden Feb 27 '17 at 20:06
• Its difficult to find an explicit reference, its considered to basic to deserve one! Can't you just say that proof is a basic calculus exercise? – kjetil b halvorsen Feb 27 '17 at 20:11
• As basic as it is, I always prefer to provide a reference. But I understand that basic results are hard to find a reference for, and leaving the proof to the reader is clearly an option. – Martin Van der Linden Feb 27 '17 at 21:07
• Temporary off-topic ping: consider voting for the spearman->spearman-rho synonym here stats.stackexchange.com/tags/spearman-rho/synonyms. Thanks – amoeba Mar 2 '17 at 9:32

You could point out that this is a weighted least squares regression with weights $$1/x_i$$.

To make the connection with the references, revert to a standard notation in which you seek to find $$\beta$$ that minimizes $$\sum \omega_i (y_i - \beta)^2.$$

This is a model with a single constant regressor $$X = \pmatrix{1\\1\\\vdots\\1}$$ and weights matrix $$W = \pmatrix{\omega_1 & 0 & \cdots & 0 \\ 0 & \omega_2 & \cdots & 0 \\\vdots & \vdots & \ddots & 0 \\ 0 & \cdots & 0 & \omega_n}.$$

I have renamed "$$x_i$$" as "$$y_i$$" (the "response") and the parameter to be estimated is $$\beta$$ instead of $$z$$. The weights are $$\omega_i=1/x_i$$. It is necessary that they all exceed $$0$$. The solution is

$$\hat\beta = (X^\prime W X)^{-1}X^\prime W y = \frac{\sum_i x_i\omega_i }{\sum_i \omega_i} = \frac{\sum_i x_i/x_i }{\sum_i 1/x_i} = \frac{n}{\sum 1/x_i},$$

QED.

2. When, as in a controlled experiment, the $$x_i$$ are viewed as fixed (and not random), the machinery of weighted least squares provides confidence intervals and prediction intervals, etc. In other words, casting the problem into this setting automatically gives you a way to assess the precision of the harmonic mean.
3. Viewing the harmonic mean as the solution to a weighted problem provides insight into its nature and, especially, to its sensitivity to the data. It is now clear that the most important contributors are those with the smallest values of $$x_i$$--and their importance has been quantified by the weights matrix $$W$$.