# What is the expected value of the logarithm of Gamma distribution?

If the expected value of $$Gamma(α,β)\mathsf{Gamma}(\alpha, \beta)$$ is $$αβ\frac{\alpha}{\beta}$$, what is the expected value of $$log(Gamma(α,β))\log(\mathsf{Gamma}(\alpha, \beta))$$? Can it be calculated analytically?

The parametrisation I am using is shape-rate.

This one (maybe surprisingly) can be done with easy elementary operations (employing Richard Feynman’s favorite trick of differentiating under the integral sign with respect to a parameter).

We are supposing $$XX$$ has a $$Γ(α,β)\Gamma(\alpha,\beta)$$ distribution and we wish to find the expectation of $$Y=log(X).Y=\log(X).$$ First, because $$β\beta$$ is a scale parameter, its effect will be to shift the logarithm by $$logβ.\log\beta.$$ (If you use $$β\beta$$ as a rate parameter, as in the question, it will shift the logarithm by $$−logβ.-\log\beta.$$) This permits us to work with the case $$β=1.\beta=1.$$

After this simplification, the probability element of $$XX$$ is

$$fX(x)=1Γ(α)xαe−xdxxf_X(x) = \frac{1}{\Gamma(\alpha)} x^\alpha e^{-x} \frac{\mathrm{d}x}{x}$$

where $$Γ(α)\Gamma(\alpha)$$ is the normalizing constant

$$Γ(α)=∫∞0xαe−xdxx.\Gamma(\alpha) = \int_0^\infty x^\alpha e^{-x} \frac{\mathrm{d}x}{x}.$$

Substituting $$x=ey,x=e^y,$$ which entails $$dx/x=dy,\mathrm{d}x/x = \mathrm{d}y,$$ gives the probability element of $$YY$$,

$$fY(y)=1Γ(α)eαy−eydy.f_Y(y) = \frac{1}{\Gamma(\alpha)} e^{\alpha y - e^y} \mathrm{d}y.$$

The possible values of $$YY$$ now range over all the real numbers $$R.\mathbb{R}.$$

Because $$fYf_Y$$ must integrate to unity, we obtain (trivially)

$$Γ(α)=∫Reαy−eydy.\Gamma(\alpha) = \int_\mathbb{R} e^{\alpha y - e^y} \mathrm{d}y.\tag{1}$$

Notice $$fY(y)f_Y(y)$$ is a differentiable function of $$α.\alpha.$$ An easy calculation gives

$$ddαeαy−eydy=yeαy−eydy=Γ(α)yfY(y).\frac{\mathrm{d}}{\mathrm{d}\alpha}e^{\alpha y - e^y} \mathrm{d}y = y\, e^{\alpha y - e^y} \mathrm{d}y = \Gamma(\alpha) y\,f_Y(y).$$

The next step exploits the relation obtained by dividing both sides of this identity by $$Γ(α),\Gamma(\alpha),$$ thereby exposing the very object we need to integrate to find the expectation; namely, $$yfY(y):y f_Y(y):$$

E(Y)=∫RyfY(y)=1Γ(α)∫Rddαeαy−eydy=1Γ(α)ddα∫Reαy−eydy=1Γ(α)ddαΓ(α)=ddαlogΓ(α)=ψ(α),\eqalign{ \mathbb{E}(Y) &= \int_\mathbb{R} y\, f_Y(y) = \frac{1}{\Gamma(\alpha)} \int_\mathbb{R} \frac{\mathrm{d}}{\mathrm{d}\alpha}e^{\alpha y - e^y} \mathrm{d}y \\ &= \frac{1}{\Gamma(\alpha)} \frac{\mathrm{d}}{\mathrm{d}\alpha}\int_\mathbb{R} e^{\alpha y - e^y} \mathrm{d}y\\ &= \frac{1}{\Gamma(\alpha)} \frac{\mathrm{d}}{\mathrm{d}\alpha}\Gamma(\alpha)\\ &= \frac{\mathrm{d}}{\mathrm{d}\alpha}\log\Gamma(\alpha)\\ &=\psi(\alpha), }

the logarithmic derivative of the gamma function (aka “polygamma“). The integral was computed using identity $$(1).(1).$$

Re-introducing the factor $$β\beta$$ shows the general result is

$$E(log(X))=logβ+ψ(α)\mathbb{E}(\log(X)) = \log\beta + \psi(\alpha)$$

for a scale parameterization (where the density function depends on $$x/βx/\beta$$) or

$$E(log(X))=−logβ+ψ(α)\mathbb{E}(\log(X)) = -\log\beta + \psi(\alpha)$$

for a rate parameterization (where the density function depends on $$xβx\beta$$).