I'm new here and hope you can help.

It's really late here in South Africa, maybe my mind just doesn't want to function now! But I need to figure out how to get a closed form expression hopefully for $E(\ln X)$ and even $E(\ln (X^2))$ if $X$ is $\Gamma(a,b)$ distributed. Any help would be greatly appreciated!!


  • Is it $E(\ln (X^2))$ or $E(\ln^2 (X))$ ? – Pedro Tamaroff Apr 28 '12 at 23:01
  • $\ln (X^2)$ is the same as $2\ln(X)$, so its expected value is just $2$ times that of $\ln X$. If you meant $(\ln X)^2$, that should be written differently. – Michael Hardy Apr 29 '12 at 0:00
  • Wikipedia says, and Maple confirms, that $E(\ln X) = -\ln b + \psi(a)$, where $\psi(t) = \frac{d}{dt} \ln \Gamma(t)$ is the digamma function. – Nate Eldredge Apr 29 '12 at 0:10
  • @NateEldredge Should be E(lnX)=lnb+ψ(a) – yliueagle Mar 23 at 15:28
  • @yliueagle: I think there is a difference of notational conventions. Compared with the definition in user26872's answer, Wikipedia replaces $b$ with $1/b$, which accounts for the sign difference. – Nate Eldredge Mar 23 at 20:02

The probability density function for the gamma distribution is $$f(x;a,b) = \frac{1}{b^a\Gamma(a)} x^{a-1}e^{-x/b},$$ so the integral we must consider is $$\mathbb{E}(\ln (X^n)) = \frac{1}{b^a \Gamma(a)} \int_0^\infty dx\, x^{a-1} e^{-x/b} \ln x^n.$$ Let $z=x/b$. We find $$\begin{eqnarray*} \mathbb{E}(\ln (X^n)) &=& \frac{n}{\Gamma(a)} \int_0^\infty dz\, z^{a-1} e^{-z}\ln (b z) \\ &=& n\ln b + \frac{n}{\Gamma(a)} \int_0^\infty dz\, z^{a-1} e^{-z}\ln z \\ &=& n\ln b + \frac{n}{\Gamma(a)} \frac{d}{d a} \int_0^\infty dz\, z^{a-1} e^{-z} \\ &=& n\left(\ln b + \frac{\Gamma'(a)}{\Gamma(a)}\right) \\ &=& n\left(\ln b + \psi(a)\right), \end{eqnarray*}$$ where we have used the definition of the gamma function, $\Gamma(a) = \int_0^\infty d x \, x^{a-1} e^{-x}$, and the digamma function, $\psi(z) = \Gamma'(z)/\Gamma(z)$.

Addendum 1: It is possible to show (using the fact that $\ln x\leq z^s/s$ for all $s>0$) that $\int_0^\infty dz\, z^{a-1} e^{-z}\ln z$ converges uniformly for $1< a < \infty$. This justifies the trick of differentiating $\Gamma(a)$.

Addendum 2: There is a possibility that the OP is interested in $\mathbb{E}((\ln X)^n)$. @Sasha dealt with this below. It can also be handled with the derivative trick, $$\begin{eqnarray*} \mathbb{E}((\ln X)^n) &=& \frac{1}{\Gamma(a)} \int_0^\infty dz\, z^{a-1} e^{-z}(\ln (b z))^n \\ &=& \frac{1}{\Gamma(a)} \int_0^\infty dz\, z^{a-1} e^{-z}(\ln b + \ln z)^n \\ &=& \frac{1}{\Gamma(a)} \int_0^\infty dz\, z^{a-1} e^{-z} \sum_{k=0}^n {n \choose k} (\ln b)^{n-k} (\ln z)^k \\ &=& \frac{1}{\Gamma(a)} \sum_{k=0}^n {n \choose k} (\ln b)^{n-k} \int_0^\infty dz\, z^{a-1} e^{-z} (\ln z)^k \\ &=& \frac{1}{\Gamma(a)} \sum_{k=0}^n {n \choose k} (\ln b)^{n-k} \frac{d^k}{d a^k} \int_0^\infty dz\, z^{a-1} e^{-z} \\ &=& \frac{1}{\Gamma(a)} \sum_{k=0}^n {n \choose k} (\ln b)^{n-k} \Gamma^{(k)}(a). \end{eqnarray*}$$ This is equivalent to the solution given by @Sasha. For $n=2$ we arrive at $$\mathbb{E}((\ln X)^2) = (\ln b + \psi(x))^2 + \psi^{(1)}(a),$$ where $\psi^{(m)}(z) = d^{m+1}(\ln \Gamma(z))/d z^{m+1}$ is the polygamma function.

The exponential generating function for expectations of the powers of $\log(X)$ is $$\begin{eqnarray} \sum_{r=0}^\infty \frac{t^r}{r!} \mathbb{E}(\log^r(X)) &=& \mathbb{E}(\sum_{r=0}^\infty \frac{t^r}{r!} \log^r(X)) = \mathbb{E}\left(X^t\right) = \int_0^\infty x^t \frac{b^{-a}}{\Gamma(a)} x^{a-1} \mathrm{e}^{-\frac{x}{b}} \mathrm{d} x = b^{t} \frac{\Gamma(t+a)}{\Gamma(a)} \end{eqnarray} $$ Hence: $$ \mathbb{E}\left(\log(X)\right) = \left. \frac{\mathrm{d}}{\mathrm{d} t} b^{t} \frac{\Gamma(t+a)}{\Gamma(a)} \right|_{t=0} = \log(b) + \psi(a) $$ $$ \mathbb{E}\left(\log^2(X)\right) = \left. \frac{\mathrm{d}^2}{\mathrm{d} t^2} b^{t} \frac{\Gamma(t+a)}{\Gamma(a)} \right|_{t=0} = \log^2(b) + 2 \log(b) \psi(a) + \psi(a)^2 + \psi^{(1)}(a) $$ where $\psi(a)$ denotes the digamma function, and $\psi^{(1)}(a)$ denotes the trigamma function.

  • Thanks for the edit. Looking at the generating function for $\mathbb{E}(\log^r X)$ is very clever. (+1) – user26872 Apr 29 '12 at 6:33

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.