# Expectation of a conditional density

I'm trying to figure out why the following equation holds: $$f_{Y}(y) = E(f_{Y|X}(y|X))$$

I have sort of "worked out" the RHS to be: \begin{align} f_{Y}(y) &= E(f_{Y|X}(y|X)) \\[5pt] &= \int \frac{f_{X,Y}(x,y)}{f_{X}(x)} f_{X}(x) dx \\[5pt] &= \int f_{X,Y}(x,y)dx \\[5pt] &= f_{Y}(y) \end{align}

Is this approach correct? If so, why do integrate with respect to $f_{X}(x)dx$ ?

• Is this a question from a course or textbook? If so, please add the [self-study] tag & read its wiki. – gung - Reinstate Monica Feb 4 '16 at 0:53
• Yes it is. I have made the required changes. – beginner Feb 4 '16 at 3:24
• apart from $y$ that's the only other variable. To be more accurate the book should have stated $E_x(\cdot)$. – sachinruk Feb 4 '16 at 3:36
• Do you know how to obtain the expected value of $g(X)$ where $g$ is a function. $f_{Y|X}(y|X)$ is just another function of $X$ since, in effect, you are holding $y$ fixed. – Zachary Blumenfeld Feb 4 '16 at 4:20
• @Sachin_ruk "To be more accurate the book should have stated Ex(⋅)" Well, certainly not, actually this habit of adding random variables as indexes to expectation signs is quite superfluous. – Did Feb 8 '16 at 17:52

To close this one:

$f_{Y|X}(y|X)$ is a function of the random variable $X$. When we write $E(f_{Y|X}(y|X))$ it is understood that the expected value is taken with respect to all "sources of randomness" present. In our case the only source of randomness is $X$, so translating $E$ to an integral we have

$$E[f_{Y|X}(y|X)] = \int_{-\infty}^{\infty} f_{Y|X}(y|X) f_{X}(x) dx$$

Using Baye's law for densities we also have

$$f_{Y|X}(y|X) = \frac{f_{X,Y}(x,y)}{f_{X}(x)}$$

and inserting into the expected value expression and simplifying we get

$$E[f_{Y|X}(y|X)] = \int_{-\infty}^{\infty} f_{X,Y}(x,y)dx$$

Integrating out $X$ from the joint density, leads in turn to $f_{Y}(y)$, as we are asked to show, because

$$f_Y(y) = \frac {d}{dy} \text {lim}_{x \to \infty} F_{X,Y}(x, y)$$

where $F_{X,Y}(x,y)$ is the joint distribution function,

$$f_Y(y) = \frac {d}{dy} \text {lim}_{x \to \infty} \int^y_{-\infty} \int_{-\infty}^x f_{X,Y}(s, t)ds\,dt$$

$$= \frac {d}{dy} \int^y_{-\infty} \int_{-\infty}^{\infty} f_{X,Y}(x, t)dx\,dt = \int_{-\infty}^{\infty} f_{X,Y}(x, y)dx$$