Find the distribution of $|X-Y|$ if $X$ and $Y$ are i.i.d. uniform on $[0,1]$

17.9k Views Asked by At

$X$ and $Y$ are independent random variables uniformly distributed over $[0,1]$. I want to find the CDF of $|X-Y|$. I could use convolution but I wan't to calculate this more "directly". Here is my set-up so far:

Let $Z = |X-Y|$. Then, $F_Z(z) = P(Z \leq z) = P(|X-Y| \leq z)$.

We can split up this last inequality into two cases because of the absolute value:

$P(|X-Y| \leq z) = P(X-Y \leq z, X \geq Y) + P(Y-X \leq z, Y > X)$

We now compute the two terms separately with integration. Let's start with the first term:

To integrate this we need to find the correct limits of integration. The constraints we must satisfy are:

  • $0 \leq x,y \leq 1$
  • $x \geq y$
  • $x - z \leq y$

All of this implies $\max\{x-z,0\} \leq y \leq \min\{1,x\}$. But, $x =1$ at most so we can replace $\min\{1,x\}$ with just $x$:

  • $\implies \max\{x-z, 0\} \leq y \leq x$

We use these boundaries to set up the integral of the first term:

$P(X-Y \leq z , X \geq Y) = \int_0^1{\mathrm{d}x \int_{\max\{x-z,0\}}^x{\mathrm{d}y}}$

Should I continue proceeding this way? Is my set up correct? Thank you!

2

There are 2 best solutions below

0
On

Since $X$ and $Y$ are iid Uniform Random variables, the joint density of $(X, Y)$ is $$f(x,y)=1, \qquad 0<x<1, \qquad 0<y<1 $$ Given that $Z=|X-Y|.$ Assume another variable $U=Y.$
The above set of transformation from $$S_{x,y}=\{(x,y): 0<x<1, 0<y<1 \}$$ to $$S_{Z,U}=\{ (z,u): 0<z<1,0<u<1, z+u\leq 1 \} $$ is not one-to-one.
Consider two sets of transformations:
\begin{eqnarray*} Z_1&=& X-Y, \textrm{ if } X>Y\\ U&=&Y \end{eqnarray*} and \begin{eqnarray*} Z_2&=& Y-X, \textrm{ if }X<Y\\ U&=&Y \end{eqnarray*} These are one-to-one. The solutions to the set of linear equations $z_1=x-y,u=y $ and $z_2=x-y,u=y $ are \begin{eqnarray*} x^{(1)}&=&z_1+u\\ y^{(1)}&=&u \end{eqnarray*} and \begin{eqnarray*} x^{(1)}&=&u-z_2\\ y^{(1)}&=&u \end{eqnarray*} The Jagobians of the first transformation is $1$ and that of second one is $-1.$
The joint density of $(z,u)$ is \begin{eqnarray*} h(z,u)&=&f(x^{(1)},y^{(1)})|J_1|+f(x^{(2)},y^{(2)})|J_2|\\ &=&1+1\\ &=&2, \qquad 0<u<1,\qquad 0<x<1, \mbox{ such that }u+z\leq 1 \end{eqnarray*} The marginal density of $Z$ is $$ h(z)=\int_0^{1-z}h(z,u)du=\int_0^{1-z}2du=2(1-z)$$ The distribution function can be obtained $ F_Z(z)=\int_0^z h(w)dw $ which is

\begin{eqnarray*} F_Z(z)&=&0,\qquad z\leq 0\\ &=& \int_0^z 2(1-w)dw=2z-z^2,\qquad 0\leq w< 1\\ &=& 1 \qquad 1\leq w \end{eqnarray*}

0
On

Let $Z=|X-Y|$. To determine the density function of the random variable $Z $ we see that

$$ \begin{aligned} \mathbb{P}(Z> z)&=\mathbb{P}(|X-Y|> z)\\ &=\mathbb{P}(X-Y>z)+\mathbb{P}(X-Y<-z)\\ &=\mathbb{P}(X>z+Y)+\mathbb{P}(Y>z+X)\\ &\text{then apply the law of total probability}\\ &=\int_0^{1-z}\mathbb{P}(X> z+y)f_Y(y)dy+\int_0^{1-z}\mathbb{P}(Y>z+x)f_X(x)dx\\ &=\int_0^{1-z}[1-(z+y)]dy+\int_0^{1-z}[1-(z+x)]dx\\ &=(1-z)^2-\left.\frac{y^2}{2}\right|_{y=0}^{1-z}+(1-z)^2-\left.\frac{x^2}{2}\right|_{x=0}^{1-z}\\ &=2\left[(1-z)^2-\frac{(1-z)^2}{2}\right]\\ &=(1-z)^2 \end{aligned} $$ Thus

$$ F_Z(z)=1-\mathbb{P}(Z>z)=1-(1-z)^2=1-1+2z-z^2=2z-z^2 $$ and finally

$$ F_Z(z)=\left\{ \begin{aligned} 0&,\quad z<0\\ 2z-z^2&, \quad 0\leq z<1\\ 1&,\quad z\geq 1 \end{aligned} \right. $$