Lehmer mean

In mathematics, the Lehmer mean of a tuple $$x$$ of positive real numbers, named after Derrick Henry Lehmer, is defined as:
 * $$L_p(\mathbf{x}) = \frac{\sum_{k=1}^n x_k^p}{\sum_{k=1}^n x_k^{p-1}}.$$

The weighted Lehmer mean with respect to a tuple $$w$$ of positive weights is defined as:
 * $$L_{p,w}(\mathbf{x}) = \frac{\sum_{k=1}^n w_k\cdot x_k^p}{\sum_{k=1}^n w_k\cdot x_k^{p-1}}.$$

The Lehmer mean is an alternative to power means for interpolating between minimum and maximum via arithmetic mean and harmonic mean.

Properties
The derivative of $$p \mapsto L_p(\mathbf{x})$$ is non-negative

\frac{\partial}{\partial p} L_p(\mathbf{x}) = \frac {\left(\sum_{j=1}^n \sum_{k=j+1}^n        \left[x_j - x_k\right] \cdot \left[\ln(x_j) - \ln(x_k)\right] \cdot \left[x_j \cdot x_k\right]^{p-1}\right)} {\left(\sum_{k=1}^n x_k^{p-1}\right)^2}, $$

thus this function is monotonic and the inequality
 * $$p \le q \Longrightarrow L_p(\mathbf{x}) \le L_q(\mathbf{x})$$

holds.

The derivative of the weighted Lehmer mean is:

\frac{\partial L_{p,w}(\mathbf{x})}{\partial p} = \frac{(\sum w x^{p-1})(\sum wx^p\ln{x}) - (\sum wx^p)(\sum wx^{p-1}\ln{x})}{(\sum wx^{p-1})^2} $$

Special cases

 * $$\lim_{p \to -\infty} L_p(\mathbf{x})$$ is the minimum of the elements of $$\mathbf{x}$$.
 * $$L_0(\mathbf{x})$$ is the harmonic mean.
 * $$L_\frac{1}{2}\left((x_1, x_2)\right)$$ is the geometric mean of the two values $$x_1$$ and $$x_2$$.
 * $$L_1(\mathbf{x})$$ is the arithmetic mean.
 * $$L_2(\mathbf{x})$$ is the contraharmonic mean.
 * $$\lim_{p \to \infty} L_p(\mathbf{x})$$ is the maximum of the elements of $$\mathbf{x}$$. Sketch of a proof: Without loss of generality let $$x_1,\dots,x_k$$ be the values which equal the maximum. Then $$L_p(\mathbf{x}) = x_1\cdot\frac{k + \left(\frac{x_{k+1}}{x_1}\right)^p + \cdots + \left(\frac{x_n}{x_1}\right)^p}{k + \left(\frac{x_{k+1}}{x_1}\right)^{p-1} + \cdots + \left(\frac{x_n}{x_1}\right)^{p-1}}$$

Signal processing
Like a power mean, a Lehmer mean serves a non-linear moving average which is shifted towards small signal values for small $$p$$ and emphasizes big signal values for big $$p$$. Given an efficient implementation of a moving arithmetic mean called smooth you can implement a moving Lehmer mean according to the following Haskell code.


 * For big $$p$$ it can serve an envelope detector on a rectified signal.
 * For small $$p$$ it can serve an baseline detector on a mass spectrum.

Gonzalez and Woods call this a "contraharmonic mean filter" described for varying values of p (however, as above, the contraharmonic mean can refer to the specific case $$p = 2$$). Their convention is to substitute p with the order of the filter Q:


 * $$f(x) = \frac{\sum_{k=1}^n x_k^{Q+1}}{\sum_{k=1}^n x_k^Q}.$$

Q=0 is the arithmetic mean. Positive Q can reduce pepper noise and negative Q can reduce salt noise.