x <- 8:5
y <- 1:4
# The arithmetic and geometric means are special cases of the
# generalized logarithmic mean.
all.equal(emean(x, y, c(2, 1)), (x + y) / 2)
all.equal(emean(x, y, c(-1, 1)), sqrt(x * y))
# The harmonic mean cannot be expressed as a logarithmic mean, but can
# be expressed as an extended mean.
all.equal(emean(x, y, c(-2, -1)), 2 / (1 / x + 1 / y))
# The quadratic mean is also a type of extended mean.
all.equal(emean(x, y, c(2, 4)), sqrt(x^2 / 2 + y^2 / 2))
# As are heronian and centroidal means.
all.equal(
emean(x, y, c(0.5, 1.5)),
(x + sqrt(x * y) + y) / 3
)
all.equal(
emean(x, y, c(2, 3)),
2 / 3 * (x^2 + x * y + y^2) / (x + y)
)
Run the code above in your browser using DataLab