Determine limits of integration to find the pdf of the difference of two random variables Homework question:
Let X and Y have the following joint density:
$$f_{X,Y}(x,y) = x(x-y)/8,\ -x < y < x,\ 0 < x < 2$$ 0  otherwise.
Give the pdf of V = X - Y.
There were similar questions on this forum, but I couldn't figure out the answer to this question by referring to those answers.
I used a simple table of sample values (below) to determine that the support of V is (0,4).
x    y    v 
-------------
2    1    1

2    0    2

2   -1    3

1   .9   .1

1    0    1

2  -1.9  3.9

I see that I will need to integrate the density with respect to x and y. I also see that x increases as y decreases if v is kept constant. However, I would like help understanding how to approach finding the limits of integration, or how to determine if I need to integrate separately over different intervals of v.
 A: The easiest way of solving this problem is to begin by drawing a rough sketch of the $x$-$y$ plane and marking on it the region where $f_{X,Y}(x,y)$ is nonzero. However, since this visual aid is resisted most
strenuously by all beginning students of probability (in which
resistance they are aided and abetted by writers of textbooks not to
mention answerers on stats.SE (including yours truly) with a few notable exceptions), here goes nothing:
The density of the difference is given by
\begin{align}
f_{X-Y}(z) &= \int_{-\infty}^\infty f_{X,Y}(x,x-z)\,\mathrm dx
&\scriptstyle{\text{standard formula}}\\
&= \int_{0}^2 f_{X,Y}(x,x-z)\,\mathrm dx 
&\scriptstyle{\text{because } f_{X,Y}(x,\cdot) = 0 ~\text{for } x<0 ~\text{or } x>2}\\
&= \int_{z/2}^2 f_{X,Y}(x,x-z)\,\mathrm dx 
&\scriptstyle{\text{because } f_{X,Y}(x,x-z) = 0 ~\text{unless }
-x < x-z < x \implies x > z/2}
\end{align}
A: Let's solve this problem by considering specific cases and then generalizing.
You want to know the distribution of V=X-Y, so let's consider a specific value of V, say 1.6
What values of X and Y make X-Y equal to 1.6? Let's be even more specific and make X = 0.5
Because X = 0.5, we have -0.5 < Y < 0.5, which means X-Y must be between 0 and 1 and thus never 1.6
In fact, for any value of X, -X < Y < X means that X-Y will be between 0 and 2X.
So, let's consider X=0.8 (the lowest possible value for which X-Y can be 1.6). If X=0.8, then X-Y=1.6 only if Y=-0.8.
[Pedantic note: -X < Y < X doesn't include the case Y=-X because it's a strict inequality; however, it turns out not to matter, since we're dealing with continuous distributions]
So what's the chance X=0.8 and Y=-0.8? Using the formula, that would be:
$\frac{1}{8} x (x-y)$
Substituting 0.8 for x and -0.8 for y, we get
$\frac{1}{8} 0.8 (0.8\, --0.8)$ which is 0.16
Of course, this doesn't mean the probability of X=0.8 and Y=-0.8 is 16%, since we're dealing with continuous distributions. It's just the contribution of X=0.8 and Y=-0.8 to the CDF of the probability X-Y=1.6
Now suppose X is an arbitrary value x (lower case), where x>0.8 (for the reason above) and x<2 (given in problem). For X-Y=1.6, we need:
$x-Y=1.6$ and thus $Y=x-1.6$
What's that probability that $Y=x-1.6$ (for a given x)? Using the formula and substituting x-1.6 for y, it's:
$\frac{1}{8} x (x-(x-1.6))$ which simplifies to $0.2 x$
Since we know x goes from 0.8 to 2, we now integrate:
$\int_{0.8}^2 0.2 x \, dx$ to get 0.336
Again, this doesn't mean the probability of V=1.6 is 33.6%, since V itself is a continuous distribution.
Now let's do the same thing for an arbitrary value of V. We know the limits of integration are $\frac{V}{2}$ and 2, and that we need:
$x-Y=v$ and thus $Y=x-v$
The PDF of this happening is:
$\frac{1}{8} x (x-(x-v))$ or $\frac{v x}{8}$
We now integrate
$\int_{\frac{v}{2}}^2 \frac{v x}{8} \, dx$
to get $\frac{v}{4}-\frac{v^3}{64}$, the final answer.
Since I've solved the problem completely, you might want to find the distribution for X+Y or X*Y or even X/Y to test your understanding.
