在有些時候,直接計算隨機變量的方差非常麻煩,此時可以用方差分解公式,將方差分解為條件期望的方差加條件方差的期望:
\[\text{Var}(X)=\text{Var}[\text{E}(X|Y)]+\text{E}[\text{Var}(X|Y)] \]
證明非常簡單,注意到
\[\begin{aligned} \text{Var}[\text{E}(X|Y)] =& \text{E}\left\{\left[\text{E}(X|Y)\right]^2\right\} - \left\{\text{E}\left[\text{E}(X|Y)\right]\right\}^2\\ =& \text{E}\left\{\left[\text{E}(X|Y)\right]^2\right\} - \left[\text{E}(X)\right]^2 \end{aligned} \]
和
\[\begin{aligned} \text{E}[\text{Var}(X|Y)] =& \text{E}\left\{\text{E}(X^2|Y) - [\text{E}(X|Y)]^2\right\}\\ =& \text{E}(X^2) - \text{E}\left\{\left[\text{E}(X|Y)\right]^2\right\} \end{aligned} \]
將上面兩式相加,即得證。