# Product of (dependant) gaussian distributions

I need to find the probability of sampling a specific point on a Gaussian Distribution.

The catch is that the mean of the first Gaussian Distribution is itself sampled from a Gaussian Distribution.

The standard deviation is known, and the mean of the second distribution is 0.

So, calling the variable to sample y:

$x \sim N(0, \rho)$

$y\mid x \sim N(x, \sigma)$

To find out the probability of sampling y, I believe I should resolve:

$$p(y) = \int^{+\infty}_{-\infty} p(y \mid x) \, p(x) \;\mathrm{d}x= \int^{+\infty}_{-\infty} \frac{1}{\sigma \sqrt{2 \pi}} \mathrm{e}^{- \frac{(y-x)^2}{2\sigma^2}} \frac{1}{\rho \sqrt{2 \pi}} \mathrm{e}^{- \frac{x^2}{2\rho^2}}\;\mathrm{d}x$$

which is the probability of sampling y from a Gaussian centered in x times the probability of sampling x from the other Gaussian, for every x.

I tried resolving it on wolframalpha but unfortunately it only works when you specify the standard deviations, while I'd like to have it parametric ( the experession will be evaluated in a program)

I also looked on the internet, but I only found situations in which both the normal distributions depended on the same variable.

I started deriving it by hand, but my calculus exam was long ago and I'm not sure I can do it correctly anymore and unfortunately I don't know any numerical computation program (like Matlab, Scilab, etc)

How can I resolve the given integral to obtain an expression which only depends on y, $\sigma$ and $\rho$?

• You might want to join forces with the author of this other question (and find a complete answer there). In your notations, $y\sim N(0,\sqrt{\rho^2+\sigma^2})$. – Did Feb 20 '16 at 9:57
• The question you linked it extremely relevant! Thanks! Might you explain how you reached $y \sim N(0, \sqrt{\rho^2 + \sigma^2})$? If you mean that y is distrubted like that, you actually solved my question! It also makes sense from my experiments with various options for $\rho$ and $\sigma$ on wolfram – Makers_F Feb 20 '16 at 10:35
• @Did I think this is the explaination math.stackexchange.com/questions/1663907/… Can you write that as an answer here, so that I can accept it and give you your deserved points? :) – Makers_F Feb 20 '16 at 10:41
• This is rather standard: en.wikipedia.org/wiki/… – Did Feb 20 '16 at 11:23

The value of the double defined integral is : $\quad\frac{1}{\sqrt{2\pi (\sigma^2+\rho^2) }}e^{-\frac{y^2}{2(\sigma^2+\rho^2)}}$

• Note that the integral proposed by you is different from the one in my question. More specifically, the second term in the integral should not depend on y (as that normal is centered on 0 and x is the variable). Am I correct? – Makers_F Feb 20 '16 at 10:50
• The integral is the same as yours. I fact there was a muddle in typing. It is corrected now. – JJacquelin Feb 20 '16 at 11:10
• Thanks! How would that change if we had multivariate normals instead? In my case the covariance matrix would be diagonal, so we can assume the components of the result vector are independant – Makers_F Feb 20 '16 at 11:45
• That's something else. You may open another question with the spécifications of the integral and the symbols used in order to make consistent the answers. – JJacquelin Feb 20 '16 at 11:53