# Finding the cdf of Y

Let $U, V$ be random numbers chosen independently from the interval $[0, 1]$ with uniform distribution. Find the cumulative distribution and density of each of the variable $Y = |U − V|$.

Attempt: I used $P (Y \le y)$, I took the positive side of the absolute value and got $P (U-V \le y)$. Later I thought about isolating $u$ to get $P (U \le y+V)$. Thus, I figured the cdf would be $F (y)=y+V$ after using a theorem.

Later, I tried to stretch the graph out in my head with the intervals from $[0,1]$. Then, I thought about the cdf and I thought it would be about $1-y$ because no matter what value you get, the function will be less than $1$ from the cdf, but it was still wrong. How should I find the correct cdf?

HINT $$\mathbb{P}[Y < y] = \mathbb{P}\left[|U-V| < y\right] = \mathbb{P}\left[-y < U-V < y\right] = \int_0^1 \int_0^1 \mathbb{I}_{\{-y < u-v < y\}} dudv$$ Can you take it from here?

• I like that indicator function...I would have written that integral with a 1 and then shown the support separately, but that is good notation – user2879934 May 8 '17 at 19:53
• @user2879934 I like it too -- especially in such cases it is useful to separate the domain of integration from shortcutting regions where the integrand is Zero, makes notation more clear :) – gt6989b May 8 '17 at 19:55

What follows is a minor modification of an answer to [What would be the graph of absolute value of $X - Y$ ] and credit for it should go to @callculus.

Consider the equation $|X-Y|\leq z$. There are two cases.

a) When $X-Y\geq 0$, the inequality becomes $X-Y\leq z \Rightarrow Y\geq X-z$.

b) When $X-Y< 0$, the inequality becomes $Y-X\leq z \Rightarrow Y\leq X+z$.

Assuming $X,Y\sim U(0,1)$, consider the picture below. We are interested in calculating the blue area. It is easier to find this value if we compute the sum of the red area and subtract it from the whole area, which is $1$.

The area of one red triangle is $\frac{(1-z)\cdot (1-z)}{2}$; thus, the area of the two red triangles is $(1-z)\cdot (1-z)$. Therefore, the blue area is $$P(|X-Y|\leq z)=1-(1-z)^2$$ Differentiating w.r.t $z$ we get the pdf $$f(z)=\begin{cases}{} 2-2z & 0\leq z \leq 1 \\ 0 & \text{elsewhere} \end{cases}$$