# PDF of difference of uniform distributions [duplicate]

Main questions are in bold but feel free to correct me if I'm wrong somewhere else. As far as possible, I need both intuition and formal explanation.

Let $$X \sim Uniform(a,b)$$ and $$Y \sim Uniform(c,d)$$ be two independent random variables and $$Z=X-Y$$ be the difference of these variables.

I need to compute $$P(\mathbf{Z} \le z) = F_\mathbf{Z}(z)$$ which I suppose is the PDF of a symmetric triangular distribution with support $$[a-d,b-c]$$. (a) Is this correct?

We know:

$$f_\mathbf{X}(x) = \frac{1}{b-a} \ \ \ \ \ \ \ \ x \in [a,b] \\\\ f_\mathbf{Y}(y) = \frac{1}{d-c} \ \ \ \ \ \ \ \ y \in [c,d]$$

Let $$Y' = -Y$$, with:

$$f_\mathbf{Y'}(y') = f_\mathbf{Y}(-y') = \frac{1}{d-c} \ \ \ \ \ \ \ \ y' \in [-d,-c]$$

(b) Is the above equation correct? Why?

We now have $$Z=X+Y'$$ and we know that the convolution/sum of random variables is as follows:

$$f_\mathbf{Z}(z) = \int_{-\infty}^\infty f_\mathbf{X}(x)\ f_{Y'}(z-x)\ \ dx$$

I understand the convolution is the evolution in the common area below two functions where one is slipped on the x-axis (example). However, I don't understand (c) why it is equivalent to the addition of random variables.

I know how to draw the convolution graphically (example), from which I can deduce the analytic form. But (d) how can I compute $$f_\mathbf{Z}(z)$$ analytically?

• Why bother defining and obtaining density for $-Y$? To obtain CoV densities, you typically use Jacobian method or CDF method. Jacobian is a good choice. You are correct we can use heuristic arguments to establish the range/continuity of the densities. If your change of variable function is $f(x,y) = x-y$ calculate the gradient, and place the multivariate densities in vector form, etc. etc. to obtain the answer. So a, b look correct but c does not look correct. Commented Feb 29 at 18:18
• I've taken liberty to add the self-study tag since I'd wager dollars-to-doughnuts this is a homework question. It will also garner a bit more patience from answerers who agree to provide didactic answers, rather than their own work. Commented Feb 29 at 18:21
• Four different methods to compute this difference are described in detail at stats.stackexchange.com/questions/41467, thereby answering (a), (b), and (d). A specific example of this question is answered at stats.stackexchange.com/questions/545409, again answering (a), (b), and (d). (b) is answered generally at stats.stackexchange.com/questions/192807. Finally, the duplicate answers (c).
– whuber
Commented Feb 29 at 18:30
• @AdamO That's not a homework, but what I really need is intuition, so the tag seems appropriate :) Commented Feb 29 at 19:05
• @whuber I haven't seen your last two links before and they helped me. I just will add this post to further complete the answer with an example. Commented Feb 29 at 19:05