Question: X and Y have the following joint probability density function. Find E[X]
$$f(x, y)= \frac{3}{620}y$$ $$0 < x < 7, y > 0, x − 4 < y < x + 4$$
My Approach:
To find the expectation of X, I first find the marginal pdf $f(x)$ by integrating y. Originally, my lower bound was $x-4$ but I changed it because if $x<4$, then $y<0$ which violates one of the constraints so:
$$\frac{3}{620}\int_{0}^{x+4}ydy = \frac{3}{620} \frac{(x+4)^2}{2} =\frac{3(x+4)^2}{1240}$$
Then, I find the expectation. I thought that the lower bound would be 4 instead of 0 as $x<4$ would not be possible for y:
$$E[X] = \int_{4}^{7}x*\frac{3(x+4)^2}{1240} dx = \frac{819}{1240} $$
However, this answer is incorrect and I'm having trouble figuring out why. If anyone can explain where I went wrong I would greatly appreciate it. Thank you!
You are correct that the marginal density for $X$ is found by applying the formula $$f(x)=\int_y f(x,y) dy\tag1$$ but your limits of integration are wrong. If you plot the region where $f(x,y)$ is defined and nonzero, it's a truncated parallelogram in the $x,y$-plane. Specifically, it can be broken into two sub-regions (draw the picture!): $$ 0 < y < x+4\qquad\text{when $0< x< 4$} $$ and $$ x-4 < y < x+4\qquad\text{when $4< x< 7$}. $$ This means you need to break up the integral (1) into two pieces, corresponding to those two regions: $$ f(x) = \begin{cases} \int_0^{x+4} \frac3{620}y\,dy& \text{if $0< x<4$}\\ \int_{x-4}^{x+4} \frac3{620}y\,dy& \text{if $4< x<7$} \end{cases}\tag2 $$ In the end you'll have a marginal density for $X$ that's defined in two pieces. (Your calculation is just the first piece, for the case $0<x<4$.) Having obtained both pieces of (2) you then proceed to compute $E[X]=\int xf(x)\,dx$, again in two pieces: $$E[X]=\int_0^4 xf(x)\,dx + \int_4^7xf(x)\,dx$$