2

I need the following integral and struggle with calculating it or finding a citable source.

$$\int_{-\infty}^{\infty}(x-\mu)^2\exp\!\left(-\frac{|x-\nu|}{\tau}\right)dx.$$

Background: I want to find an expression for the KL-Divergence from a Gaussian density $f()$ to a Laplace density $g(),$ i.e. $\mathbb{E}_g[\log g(x)]-\mathbb{E}_g[\log f(x)]$. I have done the first expectation, with user whuber's trick and(KL Divergence Normal and Laplace densities) and brute force. The trick, however doesnt apply for the second expectation, whose hardest part is the integral in the question.

Joe_base
  • 105

1 Answers1

4

Assuming $\tau>0,$ let $\xi=x-\mu$ and $\lambda=\nu-\mu.$ Then $dx=d\xi,$ and we have \begin{align*} \int_{-\infty}^{\infty}(x-\mu)^2 e^{-|x-\nu|/\tau}\,dx &=\int_{-\infty}^{\infty}\xi^2 e^{-|\xi+\mu-\nu|/\tau}\,d\xi\\ &=\int_{-\infty}^{\infty}\xi^2 e^{-|\xi-\lambda|/\tau}\,d\xi\\ &=\int_{-\infty}^\lambda \xi^2 e^{(\xi-\lambda)/\tau}\,d\xi +\int_\lambda^\infty \xi^2 e^{-(\xi-\lambda)/\tau}\,d\xi\\ &=\left[e^{(\xi-\lambda)/\tau}\tau\left(2\tau^2-2\tau\xi+\xi^2\right)\right]_{-\infty}^{\lambda}\\ &\quad-\left[e^{-(\xi-\lambda)/\tau}\tau\left(2\tau^2+2\tau\xi+\xi^2\right)\right]_{\lambda}^{\infty}\\ &=\tau\left(\lambda^2-2\lambda\tau+2\tau^2\right)+\tau\left(\lambda^2+2\lambda\tau+2\tau^2\right)\\ &=4\tau^3+2\tau\lambda^2\\ &=4\tau^3+2\tau(\nu-\mu)^2. \end{align*} The antiderivatives you can get from integration by-parts.

  • 1
    just for anyone coming from Google with a short attention span like myself: this is not the cross-entropy; to get that divide this expression by $-\tau$ (which was omitted by OP presumably to simply the integral). And remember to divide by of twice the variance of the normal too. – John Madden May 17 '23 at 19:18