# Conditional density, bivariate normal

##### Member
Let $$Z=X+Y$$ where $$X \sim N(\mu,\sigma^2)$$ and $$Y \sim N(0,1)$$ are independent. What is the conditional density of X given Z, $$f_{X|Z}(x|z)$$?

I already found that $$f_{X,Z}(x,z)=\frac{1}{2\pi\sigma}e^{-\frac{1}{2\sigma^2}[(x-\mu)^2+\sigma^2(x-z)^2]}$$ is bivariate normal and $$Z \sim N(\mu,\sigma^2+1)$$

$$f_{X|Z}(x|z)=\frac{f_{X,Z}(x,z)}{f_Z(z)}=\frac{\frac{1}{2\pi\sigma}e^{-\frac{1}{2\sigma^2}[(x-\mu)^2+\sigma^2(x-z)^2]}}{\frac{1}{\sqrt{2\pi}\sqrt{\sigma^2+1}}e^{-\frac{1}{2(\sigma^2+1)}(z-u)^2}}$$

$$f_{X|Z}(x|z)=\frac{\sqrt{\sigma^2+1}}{\sqrt{2\pi}\sigma}e^{-\frac{1}{2\sigma^2}[(x-\mu)^2+\sigma^2(x-z)^2]+\frac{1}{(2\sigma^2+1)}(z-\mu)^2}$$

After some simplifications I get

$$f_{X|Z}(x|z)=\frac{\sqrt{\sigma^2+1}}{\sqrt{2\pi}\sigma}e^{\frac{1}{2\sigma^2(\sigma^2+1)}[-(\sigma^2+1)(x^2-2\mu x+\sigma^2(x^2-2zx)-2\sigma^2\mu z]}$$

from here I'm stuck.Someone said that the conditional distribution would be $$N(Z,1)$$ but not give details.

#### JesperHP

##### TS Contributor
The mathematical expression you have written lacks a parenthesis inside the hard parenthesis [] of the exponential function making it unclear what the factor $$(\sigma^2 + 1)$$ is multiplied with

#### JesperHP

##### TS Contributor
Heres what I have:

First of all I note that (X,Z) are both linear combinations of (X,Y) that are independent so their distribution is bivariate normal.
It then holds that $$X\lvert Z$$ is normal with mean:

$$E[X\lvert Z] = \mu_x + \rho_{xz}\frac{\sigma_x}{\sigma_z} (Z- E[Z])$$

and the variance is given as

$$\sigma^2_{x\lvert z} = (1-\rho_{xz}^2)\sigma^2_x$$

to find the terms we do:

$$cov(z,z) = cov(z,x) + cov(z,y)$$

and using that $$E[Y]=0$$ and independence of X and Y:

$$Var(z)= cov(z,x) + E[ZY] = cov(z,x) + E[(X+Y)Y] = cov(z,x) + var(Y)$$

however since $$var(z) = var(x) + var(y)$$

we have: $$cov(z,x) = var(x)$$

and then $$\rho_{zx} = \frac{var(x)}{sd(x),sd(z)} = \frac{sd(x)}{sd(z)} = \frac{sd(x)}{\sqrt{var(x)+ 1}}$$

I know that this does not prove what you are assked to prove but the place where you are stuck you probably have to collect terms and complete the square in order to get the conditional distribution on the form of a normal. The above gives you what I believe you have to end up with .....

#### JesperHP

##### TS Contributor
ok so working with the density form youre first equation but dropping constant factors .. here is what I get ...

$$\frac{f_{xz}}{f_z} \propto \exp\left( - \frac{1}{2\sigma_x^2} [(x-\mu)^2 + \sigma_x^2 (x-z)^2]\right)$$

first expand the square:

$$\propto \exp\left( - \frac{1}{2\sigma_x^2 }[x^2 + \mu^2 -2x\mu + \sigma_x^2 (x^2 + z^2 - 2xz)]\right)$$

remove any additive terms in exp function not containing x since can be seperated out as factors not including x. Hence the expression is proportional to:

$$\propto \exp\left( - \frac{1}{2\sigma_x^2 }[x^2 -2x\mu + \sigma_x^2 x^2 - 2\sigma_x^2xz)]\right)$$
$$= \exp\left( - \frac{1}{2\sigma_x^2 }[(\sigma_x^2 + 1) x^2 -2(\mu+ \sigma_x^2z)x]\right)$$
$$= \exp\left( - \frac{1}{2}\frac{(\sigma_x^2 + 1)}{\sigma_x^2 }[ x^2 -2 \frac{(\mu+ \sigma_x^2z)}{(\sigma_x^2 + 1)}x]\right)$$
adding and substracting the constant C needed to complete the square:
$$= \exp\left( - \frac{1}{2}\frac{(\sigma_x^2 + 1)}{\sigma_x^2 }\left[\left[ x - \frac{(\mu+ \sigma_x^2z)}{(\sigma_x^2 + 1)}\right]^2 - C \right]\right)$$

where $$C= \left[ \frac{(\mu+ \sigma_x^2z)}{(\sigma_x^2 + 1)}\right]^2$$

and then quickly removing the constant to get the proportional expression:
$$\propto \exp\left( - \frac{1}{2}\frac{(\sigma_x^2 + 1)}{\sigma_x^2 }\left[ x - \frac{(\mu+ \sigma_x^2z)}{(\sigma_x^2 + 1)}\right]^2 \right)$$

conditional on z this is a normal kernel with the variance $$\frac{\sigma_x^2}{\sigma_x^2 + 1}$$ and conditional mean:

$$\frac{\mu}{(\sigma_x^2 + 1)} +\frac{\sigma_x^2}{\sigma_x^2 + 1} z$$
and since $$\mu = E[Z]$$ we can add and substract:

$$\frac{\mu}{(\sigma_x^2 + 1)} +\frac{\sigma_x^2}{\sigma_x^2 + 1} z + \frac{\mu \sigma_x^2}{\sigma_x^2 + 1} - \frac{\mu \sigma_x^2}{\sigma_x^2 + 1}$$

to get:

$$\mu+\frac{\sigma_x^2}{\sigma_x^2 + 1}( z - E[z])$$

to check that the result is the same as we get if we use the sentence I wrote up in the previous post