Need to find pdf of $ |X-Y| $ .I little confused and not getting answer after taking below limits. As it is symmetrical I have taken one part of triangle. Considering lower triangle limits I have taken is x from $ y+z $ to $ a $ and outer limit : y from $ 0 $ to $ a-z $ Not getting expected answer. Could any help.

Answer: $f_{z}(z)=\frac{2}{a}(1-\frac{z}{a})$


2 Answers 2


Since $X$ and $Y$ are identically distributed, $P(X-Y\le z,X\ge Y)=P(Y-X\le z,Y\ge X)$

So for $0< z<a$,

\begin{align} P(|X-Y|\le z)&=2\times P(X-Y\le z,X\ge Y) \\&=2 \int P(X-y\le z,X\ge y\mid Y=y)f_Y(y)\,dy \\&=2\int P(y\le X\le z+y)\frac{\mathbf1_{0<y<a}}{a}\,dy \\&=\frac{2}{a}\int_0^a \int_y^{\min(z+y\,,\,a)}\frac{1}{a}\,dx\,dy \\&=\frac{2}{a^2}\left[\int_0^{a-z}\int_y^{z+y}\,dx\,dy+\int_{a-z}^a\int_y^a\,dx\,dy\right] \\&=\frac{2}{a^2}\left(az-\frac{z^2}{2}\right) \end{align}

Hence the pdf of $Z=|X-Y|$ is


Needless to say, the above algebra for the CDF is not as simple as drawing a picture of the region $\{(x,y)\in[0,a]^2:|x-y|\le z\}$ and finding its area.

Here is a picture for $z=0.6$ and $a=3$: (Also see the case $a=1$ discussed in this post)

enter image description here


|X-Y| can be written as below ,

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

The limits can be visualized by drawing rectangle and |x-y| and take area of the other sides,which would be symmetry hence multiple 2.

$ F_Z(z)=1-2\int_{y=0}^{y=a-z} \int_{y+z}^{a}f(x,y) dxdy \\ $

After differentiating w.r.t z ,

$ f_Z(z)=0+2 \int_{0}^{a-z} f(y+z,y)dy \\ $

$ =\frac{2}{a^{2}}(a-z) $


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .