CDF of absolute value of difference in random variables

The area of the square that is between the two lines is the probability of the event $\{|X-Y|\le t\}$ for $0\le t\le 1$ ($t=0.5$ in the graph).

enter image description here

The area of the two triangles is the same and the area of one triangle is $(1-t)^2/2$. Hence, the area of the square that is between the two lines is given by $1-2\cdot (1-t)^2/2=1-(1-t)^2$ and the probability $$ \Pr\{|X-Y|\le t\}=1-(1-t)^2 $$ for $0\le t\le 1$.


The graphical approach is often a good one when dealing with uniform distributions, because we can interpret probabilities as areas.

Draw the unit square, and the line $y=x$ within it. Now let $z\in [0,1]$. What you have to find is the area of the polygon:

$$[0,1]^2\cap \{(x,y)\in\mathbb{R}^2:|x-y|\leq z\}$$

The set $\{(x,y)\in\mathbb{R}^2:|x-y|\leq z\}$ is just like a band centered around the first diagonal of the plane, can you see this?

More precisly, the polygon you're looking for is delimited by the points $(0,0), (0,z), (1-z,1),(1,1),(1,1-z),(z,0)$.

With a little bit of geometry, it's easy to determine its area. Now that you have the cdf, compute its derivative to get the pdf.


For fixed $z\in\mathbb{R}$ we have:$$F_Z(z)=P\left(\left|X-Y\right|\leq z\right)=\int\int1_{\left(-\infty,z\right]}\left(\left|x-y\right|\right)f_{X,Y}(x,y)dxdy$$

where $f_{X,Y}(x,y)$ denotes the density of $\langle X,Y\rangle$.

Substituting this density we arrive at:

$$F_Z(z)=P\left(\left|X-Y\right|\leq z\right)=\int_{0}^{1}\int_{0}^{1}1_{\left(-\infty,z\right]}\left(\left|x-y\right|\right)dxdy$$

Can you work this out?

If the CDF is found then the PDF can be found by differentiating.

Tags:

Probability