# Where is my mistake in derivation of total variance?

I'm obviously doing something wrong here.. could someone please point it out?

By definition of variance: $$\mathrm{Var}[Y] = \mathrm{E}\left[(Y-\mathrm{E}Y)^2\right]$$ By definition of total expectation: $$= \mathrm{E}\left[\mathrm{E}\left[(Y-\mathrm{E}Y)^2 | X \right] \right]$$ By definition of variance: $$= \mathrm{E} \left[ \mathrm{Var} [Y|X] \right]$$ which is wrong.

• Law of total expectation is that $E[E[Y|X]] = E[Y]$. Law of total variance is that $var(Y) = E(var(Y|X)) + var(E(Y|X))$. If you expand out that second display, you will find it pretty easily. – AdamO Jun 20 at 3:42
• I've seen the derivation on wikipedia. My question is about where I went wrong with my attempt.. – robsmith11 Jun 20 at 4:48

• Conditional variance is $$\operatorname{var}(Y|X)=E[(Y-E[Y|X])^2|X]$$ – gunes Jun 20 at 6:54
The expression $$\mathrm{E}\left[(Y-\mathrm{E}Y)^2 | X \right]$$ isn't the variance of Y, but rather the conditional variance of $$Y$$ with respect to $$X$$.
• @rob Consider iid variates, $Z_i\sim \text{Bernoulli}(0.5),\, i=1,2$. Let $X=Z_1$. Let $Y=Z_2+X$. Think about the distinction between Var$(Y)$ and Var$(Y|X=x)$ (one is twice the other!). Note that $Y$ is the number of heads in two tosses of a fair coin ($Z_1+Z_2$), but if you condition on $X$, then $(Y|X=x)$ is simply a constant ($x$) plus the number of heads in one toss of a fair coin ($Z_2+x$). – Glen_b Jun 20 at 6:00