Law of total variance is also known as the variance decomposition formula or Eve’s law. According to Eve’s law if we are M and N which are two random variables and lies in the same probability space and also that ‘N’ has a finite variance.

In such case we define the law of total variance as below:

$Var N$ = $E_M$ ($Var [N | M]$) + $Var_M$ ($E [N | M]$)

Where $E [N | M]$ is nothing but the conditional expected value and its value depends on the value of M.

If we have ‘n’ partitioned space with $B_1, …, B_n$ partitions being mutually exclusive as well as exhaustive, then we have,

$Var [Y]$ = $\sum_{i = 1}^n Var (Y | B_i) P (B_i)$ + $\sum_{i = 1}^n E (Y | B_i)^2 (1 – P (B_i)) P (B_i)$ - 2 $\sum_{i = 1}^n \sum_{j = 1}^{i – 1} E (Y | B_i) P (B_i) E (Y | B_j) P (B_j)$ (This is a special case). Here will discuss about law of variance in detail.

## Proof

We make use of law of total expectation to prove the law of total variance.

From the variance definition we have,

$Var [N] = E [N^2] – [E [N]]^2$

When we apply the law of total expectation to every term by applying conditions on the M that is a random variable, we have,

$Var [N]$ = $E_M [E [N^2 | M]] – [E_M [E [N | M]]]^2$

When we redo the conditional Y in second moment that too in terms of its variance and also the first moment we have,

$\rightarrow$ $Var [N]$ = $E_M [Var [N | M]$ + $[E [N | M]]^2]$ – $[E_M [E [N | M]]]^2$

**We know that the expectation of any sum is also the sum of expectations, so we can regroup the terms as follows:**

$Var [N]$ = $E_M [Var [N | M]] + (E_M [[E [N | M]]^2] – [E_M [E [N | M]]]^2)$

We see that the terms that are in parentheses are equal to the variance of E [N |M], the conditional expectations, so we get,

$\rightarrow$ $Var [N]$ = $E_M [Var [N | M]]$ + $Var_M [E [N | M]]$

Hence the law of total variance is proved.

## Examples

**Example on law of variance is given below:**

**Example:** Suppose the number of visitors to a library in a given day is N. We know Var [N] and E [N]. Let $Y_i$ represent the number of books the i^{th} number of person is reading. Taking assumption that all $Y_i$’s are independent of N and also of each other, also assuming that they have same variance and same mean as given below

$E Y_i$ = $E\ Y$.

And $Var (Y_i)$ = $Var (Y)$

If S be the total sales given by S = $sum_(i = 1)^N Y_i$, find the values for E S and Var (S).

**Solution:**

$E S$ = $E [E [S | N]]$

= $E [E [sum_(i = 1)^N (Y_i | N)] ]$

= $E [sum_(i = 1)^N E [Y_i | N]]$

= $E [sum_(i = 1)^N E [Y_i]]$

= $E [N E [Y]]$

= $E [Y] E [N]$

$Var (S)$ = $E (Var (S | N)) + Var (E [S | N])$

= $E (Var (S | N)) + Var (N E Y)$

= $E (Var (S | N)) + (E Y)^2 Var (N)$

Now $Var (S | N)$ = $\sum_(i = 1)^N\ Var (Y_i | N)$ = $\sum_(i = 1)^N\ Var (Y_i)$ = $N\ Var (Y)$

So we get,

$E (Var (S | N))$ = $E (N\ Var (Y))$ = $E N\ Var (Y)$

So we get

$Var (S)$ = $E N\ Var (Y)$ + $(E Y)^2\ Var (N)$