# Confusion about range of integration for density function

Consider the joint density function:

$$f(x,y) = \begin{cases} 2 & & \text{for } 0 \leq x \leq1 \text{ and } 0 \leq y \leq 1-x, \\[6pt] 0 & & \text{otherwise}. \end{cases}$$

From this joint density I figured out the following marginal densities:

$$f_X(x) = 2(1-x),\\ f_Y(y) = 2.$$

The marginal density $$f_Y$$ is supposedly wrong, as the solutions provided to me say to calculate $$\int^{1-y}_0 2 \, dx$$. I don't see why I need to integrate over $$[0, 1-y]$$ and not over $$[0,1]$$. I thought the range for $$x$$ does not depend on $$y$$, or does it?

• If this is homework, please add the self-study(stats.stackexchange.com/tags/self-study/info) tag. Dec 18, 2018 at 20:29
• Please: draw a picture showing where $f(x,y)$ is nonzero. That will easily answer your questions.
– whuber
Dec 18, 2018 at 20:50
• @StubbornAtom no it is not homework. this is just a practice exercise, I choose to do myself. Dec 18, 2018 at 21:34
• @whuber I get a line with the equation y = -x+1 right? When $x = 1$ $y = 1-(x=1) = 0$ I don't quite get yet, how this answers my question. Could you please give me another hint? Dec 18, 2018 at 21:37
• How did you integrate to find f(x)? What does 0 $\le$ y $\le$ (1-x) imply in terms of the random variable X and not Y? By integrating over [0,1] you are not integrating over the region specified in the question for the joint density but the region for the marginal density of Y. Dec 18, 2018 at 22:01

Comment: I simulated the joint distribution as an easy way to make the plot suggested in a previous comment. Before beginning to set limits on double integrals it is usually a good idea to sketch such a picture as a guide. I have shown R code for the first of the three plots.

set.seed(1218); m = 10^5
x1 = runif(m);  y1 = runif(m)
cond = (y1 <= 1 - x1)
x = x1[cond];  y = y1[cond]
plot(x, y, pch=".")


The simulation and plots are for orientation, and are not an exact solution to your problem. For exact solutions, maybe the first thing to do is to try to integrate the joint density $$f(x,y) = 2$$ over the triangular region to make sure the integral is $$1,$$ as required for a density function.

Then try integrating over $$x$$ to find the marginal density of $$Y,$$ which is suggested by the red line superimposed on the histogram in the third plot.

You wrote: $$\text{for } 0 \leq x \leq1 \text{ and } 0 \leq y \leq 1-x$$ That tells you the region over which you integrate.

You want to integrate out $$x$$ with $$y$$ fixed.

So you need those values of $$x$$ for which $$0\le x\le1$$ and $$0\le y \le 1-x.$$ Notice that $$y\le 1-x$$ is equivalent to $$x \le 1-y.$$

• Okay. So whenever I have this sort of relationship between x and y regarding the domain I need to have this relationship in both integration intervals? Dec 19, 2018 at 9:08
• When doing single integration, limits on integral sign need to show $x$-interval over which integration extends. For double integral, limits on two integral signs need to show $(x,y)$ region over which integration extends. Dec 24, 2018 at 1:41
• @thebilly : This is probably clearer if the constraint on $x$ and $y$ is not symmetric in the two variables. Suppose you have $0\le x \le 1$ and for each value of $x$ in that interval you have $0\le y \le 3(1-x).$ Then$\,\ldots\qquad$ Dec 25, 2018 at 19:26
• $\ldots\,\,$you have \begin{align} & \int_0^1\left( \int_0^{3(1-x)} \cdots\cdots \, dy \right) \, dx \\ \\ = {} & \iint\limits_{\left\{ (x,y) \,:\, \begin{smallmatrix} 0 \, \le \, x \,\le\, 1 \\ \&\ 0\,\le\,y\,\le\, 3(1-x) \end{smallmatrix} \right\}} \quad \cdots\cdots \, d(x,y) \\ \\ = {} & \iint\limits_{\left\{ (x,y) \,:\, 0\,\le\, x\,\le\, \frac{3-y} 3 \,\le\, 1 \right\}} \quad \cdots\cdots \, d(x,y) \\ \\ = {} & \int_0^3 \left( \int_0^{(3-y)/3} \cdots\cdots \, dx \right) \, dy. \end{align} Dec 25, 2018 at 19:32
• In other words, if you have $x$ going from $0$ to $1$ and then for any fixed value of $x$ you have $y$ going from $0$ to $3(1-x),$ and that's the same as saying $y$ is between $0$ and $3,$ and for each fixed value of $y$ between $0$ and $3$ you have $x$ going from $0$ to $(3-y)/3. \qquad$ Dec 25, 2018 at 19:37