# CDF of derived distribution $|X-Y|$ when $X$ and $Y$ are exponential random variables

I recently had to solve this same problem, except $$X$$ and $$Y$$ were uniform on $$[0,1]$$. The joint probability distribution was uniform, so I just needed to find the proportion of the area inside the region of the unit square where $$|X-Y|\leq z$$ for a given $$z$$.

I was wondering: what should I do if $$X$$ and $$Y$$ are independent exponential random variables with parameter $$\lambda$$? I believe I would have to integrate $$\int_{y_0}^{y_1} \int_{x_0}^{x_1} \lambda^2 e^{-\lambda(x+y)} \, \mathrm dx \, \mathrm dy$$

but I'm not sure what the bounds would be. How should one approach this?

## 1 Answer

You can use: $$P(\lvert X - Y \rvert < z ) = P(X - Y < z, X - Y > -z) = P(X - Y < z) - P(X - Y < z, X - Y < -z) = P(X- Y < z) - P(X-Y<-z)$$

While $$X-Y$$ has pdf that's quite easy to calculate - see another answer. Moreover, it's form allows us for closed-form expression for cdf. Said PDF is:

$$f(x) = \frac{\lambda \mu}{\lambda+\mu} \cases{e^{-\mu x} & if x > 0\cr e^{\lambda x} & if x < 0\cr}$$

where $$\mu, \lambda$$ are parameters of $$X, Y$$ respectively.