Does the following equality hold true?
$$Var[Z|X]=E[Z^2|X]-(E[Z|X])^2$$?
I need to compute $Var[Z|Y]$ where $Z=X+Y$ and $X,Y$ are independent uniform $U([0,1])$. I get a negative value using that formula, which is not possible. Why? Thank you
We get that $E[Z|X]=1/2+X$ but then i get a negative value for the variance which is obviously impossible. What is wrong with the formula above??
Note that
$$E[Z^2 \mid X] = E[X^2 + Y^2 + 2XY \mid X] = X^2 + E[Y^2] + 2XE[Y] = \frac13 + X^2 + X$$
while
$$E[Z \mid X] = E[X+Y \mid X] = E[X \mid X] + E[Y \mid X] = X + \frac12$$
so $E[Z \mid X]^2 = \frac14 + X^2 + X$. It follows that
\begin{align} V[Z \mid X] &= E[Z^2 \mid X] - E[Z \mid X]^2 \\&= \frac13+X^2+X - \left(\frac14 + X^2 + X\right) \\&= \frac13-\frac14 \\&= \frac{1}{12} \end{align}
Alternatively, we may simply calculate
$$V[Z \mid X] = V[X + Y \mid X] = V[X \mid X] + V[Y \mid X] = 0+V[Y] = \frac1{12}$$
In all of these, we use the independence of $X$ and $Y$.