# Law of total expectation: how to relate $E(X) = E(E(X|Y))$ to $E(X) = \sum_i E(X|A_i)P(A_i)$?

Below is the definition of the law of total expectation from Wiki.

The first equation states that for any $$X, Y$$ on the same probability space, then $$$$E(X) = E(E(X|Y))$$$$

It then states that one special case is

$$$$E(X) = \sum_i E(X|A_i)P(A_i)$$$$ if $$\{A_i\}_i$$ is a finite or countable partition of the sample space.

The way that the second equation is prefaced by "one special case.." leads me to think that it is a special case of the first equation.

My question is: how can one relate $$E(X) = E(E(X|Y))$$ to $$E(X) = \sum_i E(X|A_i)P(A_i)$$?

That is, if I define $$Y = \{A_i\}_{i=1}^{n}$$ as the set of partitions on the sample space, is the following correct? $$E(X) = E(E(X|Y)) = \sum_i E(X|A_i)P(A_i)$$

## 1 Answer

Since the law of total expectation $$E(E(X | Y) ) = E(X)$$ is more general, it makes sense to show how this implies $$E(X) = \sum_{i = 1}^n E(X | A_i)P(A_i)$$.

Consider $$Y_i = I_{A_i}$$ using $$\displaystyle \Omega = \dot{\cup}_{i =1}^n A_i$$ it follows that $$P \left( \sum_{i =1}^n Y_i = 1 \right) = 1$$. Then you have

\begin{align} E(X) & = \sum_{i=1}^n E(X Y_i) \\ & = \sum_{i=1}^n E(X Y_i | Y_i = 1) P(Y_i =1) + E(X Y_i | Y_i = 0) P(Y_i = 0) \\ & = \sum_{i=1}^n E( X | Y_i = 1) P(Y_i =1) + E( 0 |Y_i = 0) P(Y_i = 0) \\ & = \sum_{i=1}^n E( X | A_i) P(A_i). \end{align}

• Thanks. Is it correct to add one last line to the derivation above: i.e., $\sum_{i=1}^n E(X|A_i)P(A_i) = E(E(X|Y))$ Mar 12 at 1:20
• That is just because $E(X) = E(E(X|Y))$. Mar 12 at 2:14