# Mixed Conditioning - Two Normal Distributions

Let $Z \sim \mathcal{N}(0,1)$ and $Y|Z \sim \mathcal{N}(Z, 1)$.

Show that $f_{Z|Y}(z|y)$ is a normal density, and find the parameters of this density.

What I have so far: \begin{align*} f_Z(z) &= \phi(z)\\ f_{Y|Z}(y|z) &= \frac{1}{\sigma} \phi\left( \frac{y - \mu}{\sigma} \right) = \phi\left( y - z \right)\\ f(y,z) &= f_Z(z) \cdot f_{Y|Z}(y|z) = \phi(z) \cdot \phi\left( y - z \right) \end{align*} From the above, we can use Bayes' theorem express $f_{Z|Y}(z|y)$: \begin{align*} f_{Z|Y}(z|y) &= \frac{ f_Z(z) \cdot f_{Y|Z}(y|z)}{ f_Y(y) }\\ &= \frac{ \phi(x) \cdot \phi(y-z) }{ \int_{-\infty}^\infty f(y,z)\,\mathrm{d}z }\\ &= \frac{ \phi(x) \cdot \phi(y-z) }{ \int_{-\infty}^\infty\phi(z) \cdot \phi\left( y - z \right)\,\mathrm{d}z }\\ \end{align*} However, I am stuck at this point. I'm not exactly sure how to compute the integral in the denominator, and then express $f_{Z|Y}(z|y)$ as a normal distribution function. Is there a better way to approach this? Thanks!

$$f_{Z|Y}(z|y) = \frac{f_Z(z)f_{Y|Z}(y|z)}{\int_{-\infty}^{+\infty}{f_Z(a)f_{Y|Z}(y|a)da}} = \frac{\frac{1}{\sqrt{2\pi}} e^{-\frac{z^2}{2}} \frac{1}{\sqrt{2\pi}} e^{-\frac{(y-z)^2}{2}}} {\int_{-\infty}^{+\infty}{\frac{1}{\sqrt{2\pi}} e^{-\frac{a^2}{2}} \frac{1}{\sqrt{2\pi}} e^{-\frac{(y-a)^2}{2}}da}} = \frac{e^{-z^2+yz-\frac{y^2}{2}}}{\int_{-\infty}^{+\infty}{e^{-\frac{2a^2-2ya+y^2}{2}}da}}$$
Now we'll calculate the integral in the denominator: $$\int_{-\infty}^{+\infty}{e^{-\frac{2a^2-2ya+y^2}{2}}da} = \int_{-\infty}^{+\infty}{e^{-\frac{(\sqrt{2}a - \frac{\sqrt{2}}{2}y)^2 + \frac{y^2}{2}}{2}}da} = e^{-\frac{y^2}{4}} \int_{-\infty}^{+\infty}{e^{-\frac{(\sqrt{2}a - \frac{\sqrt{2}}{2}y)^2}{2}}da}$$ Defining $b=\sqrt{2}a$ and multiplying and dividing by $\sqrt{\pi}$ we get: $$e^{-\frac{y^2}{4}}\sqrt{\pi} \int_{-\infty}^{+\infty} {\frac{e^{-\frac{(b - \frac{\sqrt{2}}{2}y)^2}{2}}}{\sqrt{2\pi}}db}$$
Notice that we have the pdf of the normal distribution $\mathcal{N}\left(\frac{\sqrt{2}}{2}y, 1\right)$ inside the new integral. Therefore it equals 1.
Substituting $\int_{-\infty}^{+\infty}{e^{-\frac{2a^2-2ya+y^2}{2}}da} = e^{-\frac{y^2}{4}}\sqrt{\pi}$ into the initial formula we have:
$$f_{Z|Y}(z|y) = \frac{1}{\sqrt{\pi}}e^{-z^2+yz-\frac{y^2}{2}+\frac{y^2}{4}} = \frac{1}{\sqrt{\pi}}e^{-(z-\frac{y}{2})^2} = \frac{1}{\sqrt{2\pi} \frac{1}{\sqrt{2}}}e^{-\frac{(z-\frac{y}{2})^2}{2(\frac{1}{\sqrt{2}})^2}}$$
That is, $$Z|Y \sim \mathcal{N}\left(\frac{Y}{2}, \frac{1}{\sqrt{2}}\right)$$