According to the law of total expectation, we have $$\mathbb{E}X=\sum_{i=1}^n \mathbb{E}(X\mid A_{i})\cdot \mathbb{P}(A_i)$$ I am wondering if the similar formula holds for the continous case. Specifically, if $Y$ is a continous random variable with PDF $f_Y(s)$, is it true that $$\mathbb{E}X=\int_{\mathbb{R}}\mathbb{E}(X\mid Y=s)\cdot f_Y(s) \ ds\text{ ?}$$ Moreover, is it true that $$\mathbb{E}(X\mid Y\in A)\cdot\mathbb{P}(Y\in A)=\int_{A}\mathbb{E}(X\mid Y=s)\cdot f_Y(s) \ ds\text{ ?}$$ It seems to me that both are true, but I don't know how to prove it. Thanks in advance!
2 Answers
Your first question is true. Proving it uses the law of total expectation: $$ E[X] = E[ E[X|Y]] = \int_\mathbb{R} E[X|Y=s]\cdot f_y(s)\,ds $$ The idea is this: $E[X|Y=y]$ is a function of $y$ (for each value $y$, we get a number, $E[X|Y=y]$), while $E[X|Y]$ is a random variable. Namely, if $E[X|Y=y]$ is the function $g(y)$, then $E[X|Y]$ is the random variable $g(Y)$. The right hand side of the above equation is then just $\int_\mathbb{R} g(y)\cdot f_Y(y)\,dy$, which is precisely $E[g(Y)]$, which is $E[E[X|Y]]$.
For your second question, $E[X|Y]$ is defined as the (almost-surely) unique random variable for which $$ \int_A E[X|Y=y]\cdot f_Y(y)\,dy = \int_A\int_{\mathbb{R}}x\cdot f_{X,Y}(x,y)\,dx\,dy, $$ for all Borel subsets $A$ of $\mathbb R$, where $f_{X,Y}$ is the joint distribution. Taking $A=\mathbb{R}$ yields the law of total expectation. A little rearranging of the right hand side of above shows $$ \int_A E[X|Y=y]\cdot f_Y(y)\,dy =P(Y\in A)\int_{\mathbb{R}}x\cdot\frac{\int_A f_{X,Y}(x,y)\,dy}{P(Y\in A)}\,dx=P(Y\in A)\cdot E[X|Y\in A] $$ The second equality follows since $ \frac{\int_A f_{X,Y}(x,y)\,dy}{P(Y\in A)}$ is precisely the conditional density of $X$ given $Y\in A$, which can be checked by integrating it over any Borel subset $B$ of $\mathbb R$ and seeing that the result is indeed $P(X\in B|Y\in A)$.

- 279,727

- 75,930
-
OK, I got it. And how about the second equality? Is is also true? – Paweł Orliński Sep 21 '14 at 07:25
-
@PawełOrliński Edited my last post to answer your second question as well. – Mike Earnest Sep 21 '14 at 08:59
-
1+1. Nice take on a subject which confuses many math.SE users. – Did Sep 21 '14 at 09:10
-
Thanks a lot! Very clear explanation. :) – Paweł Orliński Sep 21 '14 at 21:40
Here is a non-rigorous answer. So $$ \mathbb EX = \sum_{k=-\infty}^\infty \mathbb E(X\big|Y \in [kh,kh+h)) \Pr(Y \in [kh,kh+h)) $$ for any $h>0$ (by the first formula you wrote). Now as $h \to 0$, we have that $\Pr(Y \in [s,s+h)) = f_Y(s) h + o(h)$. Let's also suppose that $\lim_{h\to 0} \mathbb E(X\big|Y \in [s,s+h))$ exists, and let's call this $\mathbb E(X\big|Y = s)$. Then using the Riemann sum we get $$ \lim_{h\to 0} \sum_{k=-\infty}^\infty E(X\big|Y \in [kh,kh+h)) \Pr(Y \in [kh,kh+h)) = \int_{-\infty}^\infty E(X\big|Y s) f)Y(s) \, ds .$$

- 26,430
- 2
- 35
- 64