I am studying probability and trying to follow an example in my textbook discussing expectation of the sum of random variables. But I'm having trouble following it.
$E[X+Y] = \int^∞_{-∞}\int^∞_{-∞}$(x+y)f(x,y)dxdy
$ = \int^∞_{-∞}\int^∞_{-∞}xf(x,y)dydx + \int^∞_{-∞}\int^∞_{-∞}yf(x,y)dxdy$
$ = \int^∞_{-∞}xf_X(x)dx + \int^∞_{-∞}yf_Y(y)dy$
$ = E[X] + E[Y]$
I am unsure how they obtain the third line down (the second equality). I understand $\int^∞_{-∞}f(x,y)dy = f_X(x)$ and vice versa for the marginal density function of Y. However, I'm a bit lost as to how they got rid of the double integral and not have to integrate x with respect to y as part of $xf(x,y)$ and likewise for y with respect to x.
Could anyone point me in the right direction?
You answered yourself. $f_X (x) = \int_{-\infty}^{\infty} f(x,y)dy$ which is the marginal distribution $X$ of $(X,Y)$.
So $$\int_{-\infty}^{\infty}\int_{-\infty}^{\infty} x f(x,y) dydx = \int_{-\infty}^{\infty}x \underbrace{\int_{-\infty}^{\infty} f(x,y) dy}_{f_X(x)}dx = \int_{-\infty}^{\infty}x f_X(x)dx = E[X]$$ and likewise for $Y$.
You can also see this for more general random variables (not only those with an absolutely continuous distribution). Given $X,Y:(\Omega,\mathcal{F})\rightarrow (\mathbb{R},\mathcal{B})$ two random variables on some probability space $(\Omega,\mathcal{F},P)$ where here $\mathcal{F}$ is the $\sigma$-algebra of events of $\Omega$ and $\mathcal{B}$ is the Borel $\sigma$-algebra of $\mathbb{R}$. Then $$E[X+Y] := \int_{\Omega} (X(\omega) + Y(\omega)) P(d\omega) = \int_{\Omega} X(\omega)P(d\omega)+\int_{\Omega} Y(\omega)P(d\omega) =E[X] + E[Y]$$ that is, the integral $\int_{\Omega} X(\omega) P(d\omega)$ is linear.