# Wondering how to get this analytical solution of $\text{E}\big(\log(f)\big)$, $f\sim$ Normal Distribution

I am reading variational inference for gaussian process modulated poisson processes and find the result (19) is unclear about its source. I am wondering how they get that. The equation is shown here

\begin{align} f &\sim N(\mu,\sigma^2)\\[1em] \text{E}_{q(f)}[\log(f^2)] &= \int_{-\infty}^{\infty} \log(f^2)N(f,\mu,\sigma^2) df\\[1em] &=-\tilde{G}\Big(-\dfrac{\mu^2}{2\sigma^2}\Big)+\log\Big(\dfrac{\sigma^2}{2}\Big)-C \end{align}

where $C$ is the Euler-Mascheroni constant. More details can be found in the paper. Thanks for any help.

Updated 19/11/2017: I almost got the same result. I am going to share my results if I have time to write them here; otherwise I may put a document here explaining what I did, which will be done after I summarize my project.

The problem boils down to computing $$f(\lambda)=\int_{0}^{+\infty}\log(x)e^{-\lambda x^2}\,dx \stackrel{x\mapsto\frac{z}{\sqrt{\lambda}}}{=}\frac{1}{\sqrt{\lambda}}\left[-\frac{\sqrt{\pi}}{4}\log\lambda+\int_{0}^{+\infty}\log(x)e^{-x^2}\,dx\right]$$ where by Feynman's trick $$\int_{0}^{+\infty}\log(x)e^{-x^2}\,dx = \left.\frac{d}{d\alpha}\int_{0}^{+\infty}x^\alpha e^{-x^2}\,dx\right|_{\alpha=0^+}=\frac{1}{4}\Gamma'\left(\frac{1}{2}\right)=\frac{\sqrt{\pi}}{4}\psi\left(\frac{1}{2}\right)$$ and by the series definition of $\psi=\frac{\Gamma'}{\Gamma}=\frac{d}{dx}\log\Gamma$ $$\psi\left(\frac{1}{2}\right)=-\gamma-\sum_{n\geq 0}\frac{1}{(n+1)(2n+1)}=-\gamma-\log 4.$$
• @RuiZhang: if $\mu\neq 0$ you have to differentiate an incomplete $\Gamma$ function, but the structure of the derivation remains essentially the same. – Jack D'Aurizio Nov 16 '17 at 16:04