I have been working on a few problems with conditional probability and there is one thing I can't seem to figure out.
If I want to solve the following problem:
Suppose $X$ and $Y$ are jointly absolutely continuous with joint density function $$f_{X,Y}(x,y) = \frac{6}{19}(x^2+y^3)$$ for $0 < x < 2$ and $0 < y < 1$, and $0$ otherwise.
a) Verify that $E(E(X|Y)) = E(X)$
b) Verify that $E(E(Y|X)) = E(Y)$.
So, firstly I computed the marginal density of both $X$ and $Y$, which is $$f_X(x) = \frac{6}{19}(x^2 + \frac{1}{4})$$ and $$f_Y(y) = \frac{4}{19}(3y^3 + 4)$$.
as well as $E(X)$, $E(Y)$, $$E(X|Y) = \frac{3(y^3 + 2)}{3y^3 + 4}$$ and $$E(Y|X) = \frac{\frac{x^2}{2} + \frac{1}{5}}{x^2 + \frac{1}{4}}$$.
When I want to show (a), I thought I'd treat $E(X|Y)$ as a random variable, and compute
$\int E(X|Y) * P(E(X|Y) = x) dx$
but I wasn't sure about the bounds, the $dx$ and I'm especially not sure of how to compute $P(E(X|Y) = x)$.
The solution is, according to my sources, given by
$\int_0^2 E(X|Y) * f_Y(y) dy$
and for (b) it is given by
$\int_0^1 E(Y|X) * f_X(x) dx$.
Can anyone explain the reasoning behind this? About their choices of bounds and $dx$ or $dy$ and why $P(E(X|Y)=x) = f_Y(y)$?
If you have a random variable $U$ with a density $f_U$ and a function $h$ then you are not surprised if I say that the mean of $V=h(U)$ is
$$E(V)=\int_{-\infty}^{+\infty}h(u)f_U(u)\ du.$$
The conditional expectation is a function of the random variable in the condition. You have $X$, $Y$ with densities and you have $E[X\mid Y]$. The latter expression can be treated as a function of $Y$. There exists a function $h(y)$ such that
$$E[X\mid Y=y]=h(y) \,\, \text{ and } \, \,h(Y)=E[X\mid Y],$$
at least with probability one. (This is an immediate consequence of the definition of the conditional expectation.)
Accordingly, based on this "function like" nature of the conditional expectation, we have
$$E[E[X\mid Y]]=\int_{-\infty}^{+\infty}h(y)f_Y(y)\ dy$$
where $$h(y)=E[X\mid Y=y].$$
The choice of bounds is a consequence of the nature of the support of $f_{X,Y}$ since
$$f_Y(y) = \frac{4}{19}(3y^3 + 4)=\begin{cases} \int_{-\infty}^{+\infty}f_{X,Y}(x,y) \ dx& \text{ if } f_{X,Y}(x,y)\ge 0\\ 0,& \text{ otherwise } \end{cases}$$
and $f_{X,Y}(x,y)$ is zero if $y\not \in [0,1]$.
So, you ought to change your formula for $f_Y(y)$ as follows
$$f_Y(y)=\begin{cases} \frac{4}{19}(3y^3 + 4),& \text{ if } 0\le y\le 1\\ 0,& \text{ otherwise.} \end{cases}$$
The same reasoning is applicable in the case of the other conditional density. So
$$f_X(x)= \begin{cases} \frac{6}{19}(x^2 + \frac{1}{4}),& \text{ if } 0\le x\le 2\\ 0,& \text{ otherwise.} \end{cases}$$