# How to compute $E[\log(X)]$ when $X$ follows a beta distribution?

Given a Beta variable $$X \sim B(\alpha\ge 2,\beta)$$, how do I compute the expectation of its logarithm $$E[\log(X)]$$?

This is deemed "obvious" on MO, but I see no easy way to compute $$\int_0^1 x^{\alpha-1}(1-x)^{\beta-1}\log x \; dx$$. Differentiating Beta function $$B(\alpha,\beta)=\int_0^1 x^{\alpha-1}(1-x)^{\beta-1}dx$$ by $$\alpha$$ results in Digamma function - is this really the way to go?

Thanks.

Wikipedia has the following for the beta distribution with all valid values for $$\alpha$$ and $$\beta$$:

$$E[\log(X)] = \psi(\alpha) - \psi(\alpha+\beta)$$

where $$\psi(x) = \frac{\Gamma'(x)}{\Gamma(x)}$$.

For completeness, the integral is calculated as follows, with $$B(\alpha,\beta)=\frac{\Gamma(\alpha)\Gamma(\beta)}{\Gamma(\alpha+\beta)}$$ $$\int_0^1 \ln x\, f(x;\alpha,\beta)\,dx \\[4pt] = \int_0^1 \ln x \,\frac{ x^{\alpha-1}(1-x)^{\beta-1}}{B(\alpha,\beta)}\,dx \\[4pt] = \frac{1}{B(\alpha,\beta)} \, \int_0^1 \frac{\partial\left( x^{\alpha-1}(1-x)^{\beta-1}\right)}{\partial \alpha}\,dx \\[4pt] = \frac{1}{B(\alpha,\beta)} \frac{\partial}{\partial \alpha} \int_0^1 x^{\alpha-1}(1-x)^{\beta-1}\,dx \\[4pt] = \frac{1}{B(\alpha,\beta)} \frac{\partial B(\alpha,\beta)}{\partial \alpha} \\[4pt] = \frac{\partial \ln B(\alpha,\beta)}{\partial \alpha} \\[4pt] = \frac{\partial \ln \Gamma(\alpha)}{\partial \alpha} - \frac{\partial \ln \Gamma(\alpha + \beta)}{\partial \alpha} \\[4pt] = \psi(\alpha) - \psi(\alpha + \beta)$$

• Actually this is a more straight forward application of the derivative under the integral sign. Jan 5, 2017 at 19:46

$$\int_{0}^1\frac{x^{\alpha-1}(1-x)^{\beta-1}} {\text{Beta}(\alpha,\beta)}\log x dx$$ we notice that $$\lim_{k\to 0}\frac{\partial}{\partial k}x^k = \log x$$ so we have an integral $$\lim_{k\to 0}\frac{\partial}{\partial k}\int_{0}^1\frac{x^{\alpha-1}(1-x)^{\beta-1}} {\text{Beta}(\alpha,\beta)}x^k dx = \lim_{k\to 0}\frac{\partial}{\partial k}\int_{0}^1\frac{x^{\alpha + k -1}(1-x)^{\beta-1}} {\text{Beta}(\alpha,\beta)} dx$$ if we set $\alpha + k \to \alpha'$ then we have $$\lim_{k\to 0}\frac{\partial}{\partial k}\frac{{\text{Beta}(\alpha',\beta)}}{{\text{Beta}(\alpha,\beta)}}\int_{0}^1\frac{x^{\alpha'-1}(1-x)^{\beta-1}} {\text{Beta}(\alpha',\beta)} dx$$ But the integral is just integrating the $\text{Beta}(\alpha',\beta)$ over the entire support i.e. equals 1.

so $$\int_{0}^1\frac{x^{\alpha-1}(1-x)^{\beta-1}} {\text{Beta}(\alpha,\beta)}\log x dx = \lim_{k\to 0}\frac{\partial}{\partial k}\frac{{\text{Beta}(\alpha + k,\beta)}}{{\text{Beta}(\alpha,\beta)}}$$ Some helper information $$\frac{\partial}{\partial \alpha}\text{Beta}(\alpha,\beta) = \text{Beta}(\alpha,\beta)(\psi(\alpha) -\psi(x+y))$$ (which is where the digamma function arises) Be careful how you take limits with $k$