# Need help proving an identity envolving expected value of a discrete random variable

I'm trying to prove the following identity, stated in Bertsekas's Introduction to Probability, 2nd edition, pg. 114:

If $A_1,...,A_n$ are disjoint events that form a partition of the sample space, with P$(A_i)>0$ for all $i$, then $$\text{E}[X]=\sum_{i=1}^{n}P(A_i)E[X|A_i]$$

Things I know that may be useful:

• $\text{E}[X|A]=\sum_{x}xP_{X|A}(x)$
• $P_{X}{(x)}=\sum_{i=1}^{n}P(A_i)P_{X|A_i}(x)$, where $A_1,...,A_n$ are disjoint events that form a partition of the sample space

This is what I've gotten so far (which isn't much):

\begin{align} E[X]&=\sum_{x}xP_{X}(x)\\ &=\sum_{x}x[\sum_{i=1}^{n}P(A_i)P_{X|A_i}(x)]\\ &=\sum_{x}\sum_{i=1}^{n}P(A_i)P_{X|A_i}(x)x \end{align}

I've tried to expand the double summation but it didn't seem to lead anywhere. Can someone help? Thanks very much in advance.

• Try swapping the summations. – Mosquite Feb 21 '17 at 1:38
• Have you tried reversing the order of the summations? – Theoretical Economist Feb 21 '17 at 1:38

## 1 Answer

You're nearly there, actually.

\begin{align} \operatorname E [X] &= \sum_x \sum_{i=1}^n \operatorname P (A_i) \operatorname P_{X\vert A_i}(x) x \\ &=\sum_{i=1}^n \sum_x \operatorname P (A_i) \operatorname P_{X\vert A_i}(x) x \\ &=\sum_{i=1}^n \operatorname P (A_i) \sum_x x \operatorname P_{X\vert A_i}(x) \\ &= \sum_{i=1}^n \operatorname P(A_i) \operatorname E [X \vert A_i] \end{align}