# 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

One more thing,

The Conditional Variance, has one more condition, where we have conditional Expectation inside the brackets. Due to this your third statement will be incorrect

$Var[Y|X]&space;=&space;E[(Y&space;-&space;E(Y|X))^2]$

• 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$$.

• Isn't that what my 3rd equation shows? – robsmith11 Jun 20 at 5:32
• @rob You called it the variance, not the conditional variance (and justified it "by definition" which doesn't show anything). – Glen_b Jun 20 at 5:55
• @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
• While @Glen_b's example is good, I'd recommend just taking the time to read up about conditional variance (wiki is an ok source). – Itamar Mushkin Jun 20 at 7:33