What's the result of the integral of this function (Gaussian related)?

35 Views Asked by At

We have:

$\int_{R} \frac{1}{\sqrt{2\pi}\sigma_{1} }e^{-\frac{ \left ( x-\mu_1 \right )^{2}}{2\sigma_{1}^{2}}}\frac{\left ( x-\mu_2 \right )^{2}}{2\sigma_{2}^{2}}dx $

How to calculate this formula?

2

There are 2 best solutions below

1
On

You want to compute $$ \mathbb{E}\left[\frac{(X-\mu_2)^2}{2\sigma_2^2}\right] $$ where $X\sim\mathcal{N}(\mu_1,\sigma_1^2)$. In that case, note that $Y=X-\mu_2$ has distribution $X\sim\mathcal{N}(\mu_1-\mu_2,\sigma_1^2)$, and then that $Z=\frac{Y}{\sqrt{2\sigma_2^2}}$ has distribution $X\sim\mathcal{N}\left(\frac{\mu_1-\mu_2}{\sqrt{2}\sigma_2},\frac{\sigma_1^2}{2\sigma_2^2}\right)$ (both using the affine transformation properties of Gaussians). It follows that $$ \mathbb{E}\left[\frac{(X-\mu_2)^2}{2\sigma_2^2}\right] = \mathbb{E}\left[Z^2\right] = \mathrm{Var}[Z]+\mathbb{E}\left[Z\right]^2 = \boxed{\frac{\sigma_1^2 + (\mu_1-\mu_2)^2}{2\sigma_2^2}}. $$


As a sanity check, when $2\sigma_2^2=1$ and $\mu_1=\mu_2$, this becomes $\sigma_1^2$, which is the right answer as then you are computing $\mathrm{Var}[X]$.

0
On

After a few straight-forward manipulations that I will leave to you, you end up with an expression of the form $$c\int_{\mathbb R} \exp(-x^2) (x+d)^2\,\mathrm dx.$$

Now use $$\int_{\mathbb R} \exp(-x^2) (x+d)^2\,\mathrm dx=\color{orange}{\int_{\mathbb R}\exp(-x^2)x^2\,\mathrm dx}+2d\color{green}{\int_{\mathbb R}x\exp(-x^2)\,\mathrm dx}+d^2\color{blue}{\int_{\mathbb R}\exp(-x^2)\,\mathrm dx}.$$

The first integral can be simplified using the substitution $y=x^2$: $$\color{orange}{\int_{\mathbb R}\exp(-x^2)x^2\,\mathrm dx}=2\int_{0}^\infty \exp(-x^2)x^2\,\mathrm dx=2\int_0^\infty\frac{\sqrt y}{2\exp(y)}\,\mathrm dy=\Gamma(3/2)=\frac{\sqrt{\pi}}2,$$

see https://en.wikipedia.org/wiki/Gamma_function.

The second integral is even easier with the substitution $y=x^2$ since that leads to an integrand that can be simply integrated.

And finally, the last integral is just the classical Gaussian error integral.