# PDF of V-U for uniform random variables on different ranges

$$U$$ and $$V$$ are uniform random variables over $$0 and $$1 respectively; the question is to calculate the density function for $$W=V-U$$. How would we go about this?

My method was to graph the square where the PDFs of $$U$$ and $$V$$ are 1, graph the line giving the region for $$V (plotting $$U$$ as x and $$V$$ as y) and just take the area of the overlap region as the CDF for $$W$$ (then differentiate it to find the PDF). I finally ended up with

$$f(w) = 0$$ for $$w<0$$, $$f(w) = w$$ for $$0, $$f(w)=2-w$$ for $$1, $$f(w)=0$$ for $$w>0$$.

Is this correct? If not, what have I done wrong in the method?

• Your best bet is to convolve the density of $V$ with the density of $-U$. – Math1000 Dec 3 at 2:02
• Your solution and answer are right. – NCh Dec 3 at 2:34