Expected value of the product of two random variables

The demonstration of this property: \begin{align}\mathsf E(XY) &= E(X)E(Y)\end{align}, where $$X$$ and $$Y$$ are two independent random variables, is the following: \begin{align}\mathsf E(XY) &= \int_\Bbb R \int_\Bbb R xy\,f_{X,Y}(x, y)\,\mathrm d x \mathrm d y\tag 1\\[1ex] &=\int_\Bbb R \int_\Bbb R xy\,f_{X}(x)f_{Y}(y)\,\mathrm d x\mathrm d y\tag 2\\[1ex] &= (\int_\Bbb R x\,f_{X}(x)\mathrm dx ) (\int_\Bbb R y\,f_{Y}(y)\mathrm dy).\tag 3\\[1ex] \end{align}

I don't understand how you can go from the second line to the last one. It might be a basic property of double integrals, but I have very little knowledge about that subject.

• Intuitively, you can think of it as $x,f_X$ being independent of $y$, and $y,f_Y$ being independent of $x$, so you can pull them out like constants. Jun 18, 2021 at 19:55
• For independent variables, $f_{X,Y}(x,y)=f_X(x)\,f_Y(y)$.
– user65203
Jun 19, 2021 at 17:03

Let's talk about the following integral $$\int_\Bbb R \int_\Bbb R xy\,f_{X}(x)f_{Y}(y)\,dx\,dy$$ Since $$X$$ and $$Y$$ are independent, it is clear that $$f_X(x)$$ does not depend on $$y$$, and $$f_Y(y)$$ does not depend on $$x$$. How do you do double integrals? First, integrate with respect to one variable, and then with respect to the other. When you're integrating with respect to $$x$$, you can pull terms dependent on $$y$$ out of that integral - since they do not depend on $$x$$ - they are essentially "constants". So, we would rewrite the integral above as: $$\int_\Bbb R \int_\Bbb R xy\,f_{X}(x)f_{Y}(y)\,dx\,dy = \int_\Bbb R y f_Y(y) \left( \int_\Bbb R x f_X(x)\, dx\right)\,dy$$ $$\left( \int_\Bbb R x f_X(x)\, dx\right)$$ does not depend on $$y$$, so we can pull it out of the integral over $$y$$. We get $$\int_\Bbb R y f_Y(y) \left( \int_\Bbb R x f_X(x)\, dx\right)\,dy = \left( \int_\Bbb R x f_X(x)\, dx\right) \left( \int_\Bbb R y f_Y(y)\, dy\right)$$ which is what we wanted.