## Friday, November 2, 2012

### Law of total variance

In probability theory, the law of total variance or variance decomposition formula, also known by the acronym EVVE (or Eve's law for short), states that if X and Y are random variables on the same probability space, and the variance of Y is finite, then
$\operatorname{var}(Y)=\operatorname{E}(\operatorname{var}(Y\mid X))+\operatorname{var}(\operatorname{E}(Y\mid X)).\,$
In language perhaps better known to statisticians than to probabilists, the two terms are the "unexplained" and the "explained component of the variance"
The nomenclature in this article's title parallels the phrase law of total probability. Some writers on probability call this the "conditional variance formula" or use other names.
Note that the conditional expected value E( Y | X ) is a random variable in its own right, whose value depends on the value of X. Notice that the conditional expected value of Y given the event X = y is a function of y (this is where adherence to the conventional rigidly case-sensitive notation of probability theory becomes important!). If we write E( Y | X = y ) = g(y) then the random variable E( Y | X ) is just g(X). Similar comments apply to the conditional variance.

Proof
The law of total variance can be proved using the law of total expectation. First,
$\operatorname{Var}[Y] = \operatorname{E}[Y^2] - \operatorname{E}[Y]^2$
from the definition of variance. Then we apply the law of total expectation to each term by conditioning on the random variable X:
$= \operatorname{E}_X\left[\operatorname{E}[Y^2|X]\right] - \operatorname{E}_X\left[\operatorname{E}[Y|X]\right]^2$
Now we rewrite the conditional second moment of Y in terms of its variance and first moment:
$= \operatorname{E}_X\!\left[\operatorname{Var}[Y|X] + \operatorname{E}[Y|X]^2\right] - \operatorname{E}_X[\operatorname{E}[Y|X]]^2$
Since the expectation of a sum is the sum of expectations, the terms can now be regrouped:
$= \operatorname{E}_X[\operatorname{Var}[Y|X]] + \left(\operatorname{E}_X\left[\operatorname{E}[Y|X]^2] - \operatorname{E}_X[\operatorname{E}[Y|X]\right]^2\right)$
Finally, we recognize the terms in parentheses as the variance of the conditional expectation E[Y|X]:
$= \operatorname{E}_X\left[\operatorname{Var}[Y|X]\right] + \operatorname{Var}_X\left[\operatorname{E}[Y|X]\right]$