In mathematics, the Lehmer mean of a tuple
x
of positive real numbers, named after Derrick Henry Lehmer, is defined as:
L
p
(
x
)
=
∑
k
=
1
n
x
k
p
∑
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
(
x
)
=
∑
k
=
1
n
w
k
⋅
x
k
p
∑
k
=
1
n
w
k
⋅
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.
The derivative of
p
↦
L
p
(
x
)
is non-negative
∂
∂
p
L
p
(
x
)
=
∑
j
=
1
n
∑
k
=
j
+
1
n
(
x
j
−
x
k
)
⋅
(
ln
x
j
−
ln
x
k
)
⋅
(
x
j
⋅
x
k
)
p
−
1
(
∑
k
=
1
n
x
k
p
−
1
)
2
,
thus this function is monotonic and the inequality
p
≤
q
⇒
L
p
(
x
)
≤
L
q
(
x
)
holds.
lim
p
→
−
∞
L
p
(
x
)
is the minimum of the elements of
x
.
L
0
(
x
)
is the harmonic mean.
L
1
2
(
(
x
0
,
x
1
)
)
is the geometric mean of the two values
x
0
and
x
1
.
L
1
(
x
)
is the arithmetic mean.
L
2
(
x
)
is the contraharmonic mean.
lim
p
→
∞
L
p
(
x
)
is the maximum of the elements of
x
.
Sketch of a proof: Without loss of generality let
x
1
,
…
,
x
k
be the values which equal the maximum. Then
L
p
(
x
)
=
x
1
⋅
k
+
(
x
k
+
1
x
1
)
p
+
⋯
+
(
x
n
x
1
)
p
k
+
(
x
k
+
1
x
1
)
p
−
1
+
⋯
+
(
x
n
x
1
)
p
−
1
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.