# Difference of two uniforms from first principles

Let $$U \sim U(0,1)$$ and $$V\sim U(0,1)$$ be two independent uniform random variables. Find the pdf of $$U=X-Y$$.

My attempt: First find the CDF of U. $$P(U\leq t) = P(X-Y \leq t) = \int_0^1 P(X\leq t+y) F_Y(y) = \int_0^1 F_X(t+y)F_Y(y)$$ Evaluating this integral, I get $$F_U(t) = \frac{t}{2}+1/3$$. To find the pdf, I differentiate this to obtain $$f_U(t) = 1/2$$ which I know is wrong but I have no idea where I went wrong.

Any help is appreciated. Thanks.

• use a geometric sketch : it will be quite evident ! Sep 16, 2020 at 17:59

Slow solution: first, find pdf of $$Z=-Y$$, which is quite straightforward in two steps: first, find CDF $$F_{Z}(z) = P(Y\geq -z)$$. The inequality changed because $$Z=\varphi(Y)$$ is a decreasing function, therefore you want $$Y\geq \varphi^{-1}(z)$$. Once you have got it, differentiate wrt $$z$$ to get $$f_Z(z): Z \sim R[-1,0]$$ is Now you have $$U=X+Z$$ It is easier to find pdf of $$U$$ rather than CDF using convolution formula: $$f_{U}(u) = \int f_{Z}(u-x)f_{X}(x)dx$$ Obvisouly $$f_{Z}(u-x)$$ is not $$0$$ only when $$-1 . Therefore you can split the support of the integral into 2 intervals: $$\int_{0}^{xu}^{1}f_{X}(x)dx \ \text { if } 0 Outside of these intervals it is $$0$$.
• Thanks a ton! How does this expression imply $1-|u|$ for $u \in[-1,1]$? Sep 16, 2020 at 21:27
• Solve both integrals, and you get your expression (or $\{1+u, 1-u\}$) if you wish, which is the same thing