# Expected Value for 2 Random Variables with Joint Probability Distribution

I have trouble with determining the domain for integration in the case of having a joint pdf when one variable depends on the other. There are two examples I don't quite understand, and hopefully, you can help me out.

Example 1: $$f(x,y)=2, 0\le x\le y \le 1$$ In the solution, the expected values for $$X$$ and $$Y$$ $$E[X]$$ and $$E[Y]$$ are given as: $$E[X]=\int_{0}^{1} \int_{x}^{1} 2x \,dy \,dx$$ $$E[Y]=\int_{0}^{1} \int_{y}^{0} 2y \,dx \,dy$$ In the first case, we are using $$1$$ and $$x$$ for the inner integral. In the second case, I believe we are supposed to use $$x$$ and $$1$$ rather than $$0$$ and $$1$$(based on inequality). Am I wrong? I don't see why in the first case we chose $$x$$ rather than $$0$$ for the initial value while in the second case we chose $$0$$ over $$x$$ as an initial value.

Example 2:(similar concept but applied to marginal pdf):

Let $$X$$ and $$Y$$ have a joint pdf $$f(x,y)=1, x\le y\le x+1, 0\le x\le1$$ Then, $$f_{X}(x)=\int_{x}^{x+1}1dy,0\le x\le1$$ $$$$f_{Y}(y)=\begin{cases} \int_{0}^{y}1dx=y, & \text{0\le y\le1}.\\ \int_{y-1}^{1}1dx=2-y, & \text{1\le y\le2}. \end{cases}$$$$ Why does here $$f_{Y}(y)$$ branches into 2 parts and why can't we simply say that $$f_{Y}(y)=\int_{x}^{x+1}1dx$$ ? (simillar to $$f_{X}(x)$$) . I do get that we need to get a function in terms of $$y$$ but all I am doing is just looking at the given inequality.

I ask these 2 questions together because I believe the issue comes from the same misunderstanding on my part.

• Sketch the domains of integration in the plane; that will make everything obvious.
– whuber
Nov 19, 2020 at 18:12
• Could you please correct your question title as it is missing at least one noun? Nov 20, 2020 at 10:04

When writing (correctly) $$\mathbb E[X]=\int_{0}^{1} \int_{x}^{1} 2x \,\mathrm dy \,\mathrm dx$$ one skips intermediate steps: \begin{align} \mathbb E[X] &= \int_{\mathbb R^2} x f(x,y)\,\,\mathrm d(x,y)\tag{definition}\\ &= \int_{\mathbb R^2} x\times2\times\mathbb I_{\underbrace{\{(x,y);\,0\le x\le y \le 1\}}_{\text{support set}}}(x,y) \,\,\mathrm d(x,y)\\ &= \int_{\underbrace{(0,1)^2}_{\text{max range}}} x\times2\times\mathbb I_{\{(x,y);\,0\le x\le y \le 1\}}(x,y) \,\,\mathrm d(x,y)\\ &= \int_0^1 2x \Big\{ \int_0^1 \mathbb I_{\underbrace{\{y;\,x\le y \le 1\}}_{\text{y sliced support}}}(y)\,\mathrm dy \Big\} \,\mathrm dx\\ &= \int_0^1 2x \Big\{\int_x^1 \,\mathrm dy\Big\} \,\mathrm dx \end{align} The same applies to $$\mathbb E[Y]$$: \begin{align} \mathbb E[Y] &= \int_{\mathbb R^2} y f(x,y)\,\,\mathrm d(x,y)\tag{definition}\\ &= \int_{\mathbb R^2} y\times2\times\mathbb I_{\underbrace{\{(x,y);\,0\le x\le y \le 1\}}_{\text{support set}}}(x,y) \,\,\mathrm d(x,y)\\ &= \int_{\underbrace{(0,1)^2}_{\text{max range}}} y\times2\times\mathbb I_{\{(x,y);\,0\le x\le y \le 1\}}(x,y) \,\,\mathrm d(x,y)\\ &= \int_0^1 2y \Big\{ \int_0^1 \mathbb I_{\underbrace{\{x;\,0\le x\le y\}}_{\text{x sliced support}}}(x)\,\mathrm dx \Big\} \,\mathrm dx\\ &= \int_0^1 2y \Big\{\int_0^x \,\mathrm dx\Big\} \,\mathrm dy \end{align}