[Math] Integral of product of two normal distribution densities

integrationnormal distribution

I want to compute the integral:

$\displaystyle \int^{\infty} _{-\infty} \frac{1}{\sqrt{2\pi}} e^{-\frac{(y-x)^2}{2}} \frac{1}{\sqrt{2\pi}ab} e^{-\frac{x^2}{2(ab)^2}} dx$

Maybe we can use that for a normal distribution with mean $\mu$ and variance $\sigma^2$ we have

$\displaystyle \int^{\infty} _{-\infty} \frac{1}{\sqrt{2\pi}\sigma} e^{-\frac{(x-\mu)^2}{2 \sigma^2}} dx = 1$

In an effort to write the integral in this form, I tried to take the exponents together. This gives:

$\displaystyle -\frac{(y-x)^2}{2} – \frac{x^2}{2(ab)^2} = \frac{-[(ab)^2 (y-x)^2 + x^2]}{2(ab)^2} = \frac{-[(ab)^2 (y^2 -2xy +x^2) + x^2]}{2(ab)^2}$

But this leads to nowhere. Any suggestions?

Best Answer

Actually, you're on the right track. Just keep on going with $$\begin{align}(ab)^2(y^2-2xy+x^2)+x^2 & =(a^2b^2+1)x^2-2a^2b^2yx+a^2b^2y^2 \\ & =(a^2b^2+1)\left[x^2-2\frac{a^2b^2y}{a^2b^2+1}x\right]+a^2b^2y^2 \\ & =(a^2b^2+1)\left[\left(x-\frac{a^2b^2y}{a^2b^2+1}\right)^2-\frac{a^4b^4y^2}{(a^2b^2+1)^2}\right]+a^2b^2y^2 \\ & =(a^2b^2+1)\left(x-\frac{a^2b^2y}{a^2b^2+1}\right)^2+\left[a^2b^2-\frac{a^4b^4}{a^2b^2+1}\right]y^2 \\ & =(a^2b^2+1)\left(x-\frac{a^2b^2y}{a^2b^2+1}\right)^2+\left(\frac{a^2b^2}{a^2b^2+1}\right)y^2 \\ \end{align}$$ Then we know that $$\int_{-\infty}^{\infty}e^{\frac{-(a^2b^2+1)\left(x-\frac{a^2b^2y}{a^2b^2+1}\right)^2}{2a^2b^2}}dx=\int_{-\infty}^{\infty}e^{-\frac{(x-\mu)^2}{2\sigma^2}}dx=\sqrt{2\pi}\sigma$$ Where $$\mu=\frac{a^2b^2y}{a^2b^2+1}$$ $$\sigma=\frac{ab}{\sqrt{a^2b^2+1}}$$ So now you have $$\begin{align}\int_{-\infty}^{\infty}\frac1{\sqrt{2\pi}}e^{-\frac{(y-x)^2}{2}}\frac1{\sqrt{2\pi}ab}e^{-\frac{x^2}{2(ab)^2}}dx & =\frac1{\sqrt{2\pi}}\frac1{\sqrt{2\pi}ab}\frac{\sqrt{2\pi}ab}{\sqrt{a^2b^2+1}}e^{-\frac{y^2}{2\left(\sqrt{a^2b^2+1}\right)^2}} \\ & = \frac1{\sqrt{2\pi}\sqrt{a^2b^2+1}}e^{-\frac{y^2}{2\left(\sqrt{a^2b^2+1}\right)^2}} \end{align}$$ So the means add, $0+0=0$, as do the variances, $1+a^2b^2=\left(\sqrt{a^2b^2+1}\right)^2$, just like they are supposed to.