[Math] How to compute variance of a conditional expectation and vice versa

expectationnumber theoryprobabilitystatisticsvariance

I am trying to use the law of total variance which is

$$\operatorname{Var}(X) = \text{Var}(E(X\mid Y)) + E(\operatorname{Var}(X\mid Y))$$

But I honestly have no idea how to compute either one of these terms. I have the following example:

Let $y$ be the value you get when rolling a 4-sided die. Then you roll $y$ 6-sided dice. Let $x$ be the sum of all the values. What is the variance of $x$?

I know that $E(y) = 5/2$ and $\operatorname{Var}(y) = 5/4$ by use of $\operatorname{Var}(y) = E(y^2) – E(y)^2$, but I don't know how to compute the conditional terms properly above.

I already know the answer is $1085/48$ but want to know how to get there.

Best Answer

The way to evaluate the nested expectations and variances is to regard $y$ as fixed (deterministic) in the inner calculation, then regard it as random in the outer.

So for example, if you roll $y$ 6-sided dice (that are fair and numbered from $1$ to $6$), and $X$ represents the sum of the values rolled, then $$\operatorname{E}[X \mid Y] = \operatorname{E}[X_1 + X_2 + \cdots + X_Y \mid Y] = \sum_{i=1}^Y \operatorname{E}[X_i] = \frac{7}{2} Y,$$ where $X_i$ is the roll of the $i^{\rm th}$ six-sided die. Since each such roll is independent and identically distributed, with mean $7/2$, we obtain the above result. Then we calculate the variance of this expression: $$\operatorname{Var}[7Y/2] = \frac{49}{4} \operatorname{Var}[Y] = \ldots,$$ which I leave to you to finish from your own previous calculations.

Similarly, $$\operatorname{Var}[X \mid Y] = \operatorname{Var}[X_1 + X_2 + \cdots + X_Y \mid Y] \overset{\text{ind}}{=} \sum_{i=1}^Y \operatorname{Var}[X_i],$$ where in this case we are able to claim that the variance of the conditional sum is equal to the sum of the variances only because of the independence of the $X_i$s.

The takeaway is that the inner calculation will always result in a function of the random variable on which the conditioning takes place.

Related Question