3

I have probability density of function of some data (it's triangular.) How can I calculate harmonic or geometric mean of the data? I know for calculating arithmetic mean of a variable like $K$, I have to calculate $\int_{0}^\infty K.P(K)dK$ but I don't have any ideas for other types of averaging methods (Harmonic and geometric).

2 Answers2

3

Geometric mean of the data $(x_1,\ldots,x_n)$ with $x_i>0$ is defined as $g=(\prod_{i=1}^n x_i)^{1/n}$.

Taking logarithm we have $\ln g=\frac{1}{n}\sum_{i=1}^n \ln x_i$, the arithmetic mean of the $\ln x_i$s.

Suppose $G$ is the geometric mean of the random variable $X$ where $P(X>0)=1$. Then analogous to the previous statement you have $\ln G=E(\ln X)$, that is, $$G=\exp\left(E(\ln X)\right)$$

For $x_i\ne 0$, harmonic mean is defined as the reciprocal of the arithmetic mean of $(\frac{1}{x_1},\ldots,\frac{1}{x_n})$.

Similarly harmonic mean of a random variable $X$ (with $P(X\ne 0)=1$) is defined as $$H=\frac{1}{E\left(\frac1X\right)}$$

StubbornAtom
  • 17,052
2

I have attempted to calculate the distribution functions (pdf) $g_{M}(w)$ of the three means $M$ of $n$ independent non negative random variables $x_{1}, ..., x_{n}$ with identical pdf $f(x)$.

The arithmetic, geometric, and harmonic mean are defined by

$$A(X) = \frac{1}{n} \sum_{i=1}^n x_{i}$$

$$G(X) = (\prod_{i=1}^n x_{i} )^{\frac{1}{n}}$$

and

$$H(X) = \frac{n}{\sum_{i=1}^n \frac{1}{x_{i}}}$$

respectively.

The pdf is calculated using this formula

$$g_{M}(w) = \int_ \,dx f(x)\delta(w-M(x)) $$

Here $\delta(\cdot)$ is Dirac's delta function, $M(x)$ is the mean in question, and we have used a vector notation in which $dx$ and $f(x)$ are understood as a product taken over all $i=1,\ldots,n$.

To begin with, only the results are presented.

For definiteness we consider two types of pdfs

a) $f(x) =1, x\in[0,1]$
b) $f(x) = e^{-x}, x\ge 0$

Arithmetric mean, uniform distribution (a)

$$a_{u}(n,w) = \frac{n^n}{2 (n-1)!} \sum _{i=0}^n (-1)^i \binom{n}{i} \left(w-\frac{i}{n}\right)^{n-1} \text{sgn}\left(w-\frac{i}{n}\right)$$

Here $\text{sgn}(x) = -1$ for $x\lt 0$, $=+1$ for $x\gt 0$.

The first two moments are

$$m_{1} = \frac{1}{2}$$

$$m_2 = \frac{1}{4} + \frac{1}{12 n}$$

Arithmetric mean, exponential distribution (b)

$$a_{e}(n,w)=\frac{n^n w^{n-1} \exp (-n w)}{(n-1)!}$$

The first two moments are

$$m_{1} = 1$$

$$m_{2} = 1 - 1/n$$

Geometric mean, uniform distribution (a)

$$g_u(n,w)=\frac{n^n \left(w \log \left(\frac{1}{w}\right)\right)^{n-1}}{(n-1)!}$$

The first two moments and the central second moment and their asymptotic behaviour for large $n$ are, resp.

$$m_1 = \int_{0}^1 w g_u(n,w)\,dw= \left(\frac{n}{n+1}\right)^n\simeq \frac{1}{e}+O(\frac{1}{n})$$

$$m_2 = \int_{0}^1 w^2 g_u(n,w)\,dw= \left(\frac{n}{n+2}\right)^n\simeq \frac{1}{e^2}+O(\frac{1}{n})$$

$$\sigma^2 = m_2-m_1^2 =\simeq\frac{e^{-2 \gamma } \pi ^2}{6 n}+O(\frac{1}{n^2})$$

Geometric mean, exponential distribution (b)

$$g_e(n,w)=n w^{n-1} G_{0,2}^{2,0}\left(w^n| \begin{array}{c} 0_{1},0_{2},...,0_{n} \\ \end{array} \right)$$

here $G$ is the MeijerG-function, a generalization of the generalized hypergeometric function (https://en.wikipedia.org/wiki/Meijer_G-function). Its second parametric argument is meant to contain $n$ zeroes.

From the definition of the MeijerG-function as a complex line integral we find the following integral representation for the pdf

$$g_{e}(n,w) = \frac{1}{2 \pi } n \;w^{n/2-1} \int_{-\infty }^{\infty } w^{i n t}\; \Gamma \left(\frac{1}{2}-i t\right)^n \, dt$$

The first two moments and the central second moment and their asymptotic behaviour for large $n$ are, resp.

$$m_1 = \int_{0}^1 w g_e(n,w)\,dw= \Gamma \left(\frac{n+1}{n}\right)^n\simeq e^{-\gamma } \left(\frac{\pi ^2}{12 n}+1\right)+O(\frac{1}{n^2})$$

$$m_2 = \int_{0}^1 w^2 g_e(n,w)\,dw= \Gamma \left(\frac{n+2}{n}\right)^n\simeq e^{-2 \gamma } \left(\frac{\pi ^2}{3 n}+1\right)+O(\frac{1}{n^2}) $$

$$\sigma^2 = m_2-m_1^2 = \simeq \frac{e^{-2 \gamma } \pi ^2}{6 n}+O(\frac{1}{n^2})$$

Here $\Gamma$ is the Gamma function and $\gamma$ is Euler's gamma.

Harmonic mean, uniform distribution (a)

For $n=2$ I find

$$h_u(2,w) = 2 \left(\frac{w-1}{w-2}+ \frac{w}{2} \log \left(\frac{2-w}{w}\right)\right)$$

The first two moments are

$$m_1 = \frac{4}{3} (1-\log (2)), m_2 = 3-4 \log (2), \sigma^2 =\frac{1}{9} \left(11-16 \log ^2(2)-4 \log (2)\right) $$

For $n\ge 3$ I did not find an expression for the pdf.

Remark: due to a mistake I found (with the help of Mathematica, 21.10.19) the following expression for the pdf of the quantity $\frac{\prod_{i=1}^3 x_{i}}{\sum_{i=1}^3 x_{i}}$

$$\sqrt{\frac{w}{3}} \left(6 \tan ^{-1}\left(\sqrt{\frac{w}{3}}\right)-\pi \right)-\left(2-\frac{4 w}{3}\right) \log \left(\frac{\sqrt{\frac{1}{3} w \left(\frac{w}{3}+1\right)}}{1-\frac{w}{3}}\right)$$

For $n \ge 4$ no result for the pdf was found.

However, the general first two moments can be given in the form of an integral with the first two terms given explicitly

$$m_1(n) = E\left[ \frac{n}{\sum_{i=1}^n \frac{1}{x_{i}}} \right]= n \int_{0}^\infty E\left[ e^{-q\sum_{i=1}^n \frac{1}{x_{i}}}\right]\,dq= n \int_{0}^\infty E\left[ e^{-q \frac{1}{x}}\right]^n\,dq\\=n \int_{0}^\infty \left(e^{-q} - q \Gamma(0,q)\right)^n\,dq \\=\left\{\frac{1}{2},\frac{4}{3} (1-\log (2))\right),3 \left(-3 \operatorname{Li}_2(-2)-\frac{\pi ^2}{4}+\frac{3}{4}-\frac{1}{4} 9 \log (3)\right) \}$$

Here $\Gamma(a,q)=\int_{q}^\infty t^{a-1} e^{-t}\,dt$ is the incomplete Gamma function.

$$m_2(n) = E\left[ (\frac{n}{\sum_{i=1}^n \frac{1}{x_{i}}})^2 \right]= n^2 \int_{0}^\infty q E\left[ e^{-q\sum_{i=1}^n \frac{1}{x_{i}}}\right]\,dq\\= n^2 \int_{0}^\infty q E\left[ e^{-q \frac{1}{x}}\right]^n\,dq=n^2 \int_{0}^\infty \left(q e^{-q} - q^2 \Gamma(0,q)\right)^n\,dq \\=\left\{\frac{1}{3},\frac{3}{2}-\log (4)\right\}$$

Harmonic mean, exponential distribution (b)

For $n=2$ I find

$$h_e(2,w) = e^{-w} w (K_0(w)+K_1(w))$$

where $K_m(w)$ is a modified Bessel function of the second kind.

The moments form an interesting sequence

$$\left\{\frac{2}{3},\frac{4}{5},\frac{48}{35},\frac{64}{21},\frac{640}{77},\frac{3840}{143},\frac{14336}{143},\frac{1032192}{2431},\frac{92897280}{46189},\frac{44236800}{4199}\right\}$$

Notice the erratic behaviour of the numerator and the denominator. Both are not contained in OEIS.

For $n\ge 3$ I found no solution for the pdf.

However, the moments can be calculated generally.

Here we need

$$E\left[\exp \left(-\frac{q}{x}\right)\right]=\int_0^{\infty } \exp (-x) \exp \left(-\frac{q}{x}\right) \, dx=2 \sqrt{q} K_1\left(2 \sqrt{q}\right)$$

hence we have, with the fist few terms given explicitly

$$m_{1}(n) = n \int_{0}^{\infty} \left(2 \sqrt{q} K_1\left(2 \sqrt{q}\right)\right)^n\,dq\\=\left\{1,\frac{2}{3},\frac{3}{16} \sqrt{\pi } G_{3,3}^{3,2}\left(4\left| \begin{array}{c} \frac{1}{2},\frac{3}{2},3 \\ \frac{3}{2},\frac{5}{2},\frac{7}{2} \\ \end{array} \right.\right),\frac{1}{4} \pi G_{4,4}^{3,3}\left(1\left| \begin{array}{c} -3,-2,-1,\frac{1}{2} \\ -1,0,1,-\frac{5}{2} \\ \end{array} \right.\right)\right\}\\\simeq \{1.,0.666667,0.541457,0.472975,0.428744,0.397334\}$$

$$m_{2}(n) = n^2 \int_{0}^{\infty} q \left(2 \sqrt{q} K_1\left(2 \sqrt{q}\right)\right)^n\,dq\\=\left\{2,\frac{4}{5},\frac{9}{64} \sqrt{\pi } G_{3,3}^{3,2}\left(4\left| \begin{array}{c} \frac{1}{2},\frac{3}{2},4 \\ \frac{5}{2},\frac{7}{2},\frac{9}{2} \\ \end{array} \right.\right),\frac{1}{4} \pi G_{4,4}^{3,3}\left(1\left| \begin{array}{c} -4,-3,-2,\frac{1}{2} \\ -1,0,1,-\frac{7}{2} \\ \end{array} \right.\right)\right\}\\ \simeq \{2.,0.8,0.497484,0.364876,0.291227,0.24452\}$$

Here $G$ is the MeijerG-function.