# Marginal Density and Expected value of two continous random variables

I'm trying to find the expected value of a random variable using its marginal pdf.

Suppose the joint pdf of $X$ and $Y$ is $$f_{XY}(x,y) = \begin{cases}1 && 0<x<1, x<y<x+1\\0 && otherwise\end{cases}$$ Find E(X) and E(Y).

Here's my process for finding $E(X)$

$$f_x = \int_{-\infty}^{\infty}f_{XY}dy = \int_{0}^{1}1dy + \int_{1}^{x+1}1dy\\=1 + x\\$$

Also

$$f_y = \int_{-\infty}^{\infty}f_{XY}dx = \int_{0}^{y}1dy + \int_{0}^{1}1dy\\=y + 1\\$$

Hence

$$E(X)=\int_{-\infty}^{\infty}xf_{X}dx = \int_{0}^{y}x(1+x)dx + \int_{0}^{1}x(1+x)dx$$

In which the final answer will be a function of $y$, hence I stopped. The book's answer is $1/2$.

Can you point out where did I go wrong?

• Using indicator functions to express densities would save you, nolens volens... – Did Oct 18 '17 at 16:02

## 1 Answer

\begin{eqnarray} E(X) &=& \int_{-\infty}^{+\infty}{\rm d}x \int_{-\infty}^{+\infty}{\rm d}y ~ xf_{XY}(x,y) \\ &=& \int_{0}^1{\rm d}x \int_{x}^{x+1}{\rm d}y~ xf_{XY}(x,y) \\ &=& \int_{0}^1{\rm d}x ~x \underbrace{\color{\red}{\left(\int_{x}^{x+1}{\rm d}y~ f_{XY}(x,y)\right)}}_{f_X(x)}\\ &=& \int_0^1{\rm d}x ~x\color{red}{1} = \left.\frac{1}{2}x^2\right|_0^1 \\ &=& \frac{1}{2} \end{eqnarray}