# CDF and PDF of absolute difference of two exponential random variables.

I'm studying probability theory and came across an exercise problem that I would like to request some help with. Here's the problem:

Let $$X$$ and $$Y$$ be i.i.d. random variables with Expo($$1$$), and let $$Z = | X - Y |$$. Find the CDF and PDF of $$Z$$.

My attempt

\begin{align} F_Z(z) & = P(Z \le z)\\ & = P(|X - Y| \le z) \\ & = P(-z \le X - Y \le z) \\ & = P(X - Y \le z) - P(X - Y \le -z) \\ & = P(X \le Y + z) - P(X \le Y - z) \\ & = F_X(Y + z) - F_X(Y - z) \\ & = (1 - e^{-(Y + z)}) - (1 - e^{-(Y - z)}) \\ & = e^{-(Y - z)} - e^{-(Y + z)} \\ \end{align}

\begin{align} f_Z(z) & = \frac{d}{dz}F_Z(z) \\ & = \frac{d}{dz}(e^{-(Y-z)} - e^{-(Y + z)}) \\ & = e^{-(Y - z)} + e^{-(Y + z)} \\ \end{align}

The problems/questions that I have are

1. I'm not sure if this approach is even correct. I'm sure that I have to find the CDF first then differentiate it, but is this the correct way?

2. How do I handle the $$Y$$ in the final equations?

Thank you.

Sadly, your answer cannot be correct because the random variable $$Y$$ remains in your CDF and PDF. The CDF of $$Z$$ should be only a function of $$z$$ and the parameters.

Your initial approach is sound, however. Let's see how to complete it.

$$\Pr[Z \le z] = \Pr[X \le Y + z] - \Pr[X \le Y - z]$$ is correct. Now, let's see how to attack each term on the right. We have $$\Pr[X \le Y + z] = \int_{y=0}^\infty \Pr[X \le y + z] f_Y(y) \, dy,$$ by the law of total probability. This in turn yields $$\Pr[X \le Y + z] = \int_{y=0}^\infty (1 - e^{-(y+z)}) e^{-y} \, dy = 1 - e^{-z}/2.$$ Similarly, $$\Pr[X \le Y - z] = \int_{y=0}^\infty \Pr[X \le y - z]f_Y(y) \, dy.$$ However, you must be careful here. Whereas in the first case we had no issues with $$y + z < 0$$, since $$y$$ and $$z$$ must both be nonnegative, in this situation we could have $$0 \le y < z$$, in which case $$\Pr[X \le y-z] = 0$$, because $$X$$ cannot be negative. Consequently, we can write this as $$\Pr[X \le Y - z] = \int_{y=z}^\infty \Pr[X \le y-z] f_Y(y) \, dy,$$ noting that the lower limit of integration can begin at $$y = z$$, since on the interval $$y \in [0,z)$$, the integrand is zero.

I have left the remaining calculations as an exercise. What is your result? Is it surprising? If so, how might you go about verifying it?

• Hello Mr./Ms. @heropup thank you for the very kind answer. I've actually managed to follow your guidance and solve the problem and have came to the conclusion that $P(Z \le z) = 1 - e^{-z}$, which gives me the conclusion (correct me if I'm wrong) that $Z$ is also i.i.d. to $X$ and $Y$. – Seankala Nov 17 '18 at 6:20
• If it's not too much trouble, I had another question regarding your answer. How did you come to the conclusion to use the Law of Total Probability? Perhaps my initial understanding is not sufficient, but that method did not even occur to me at first. – Seankala Nov 17 '18 at 6:22

Since $$Z > 0$$ a.s. we can assume that $$z > 0$$ in $$P(Z \leq z)$$. Then you get $$P(X \leq Y +z) - P(X \leq Y -z)$$. Since $$X$$ and $$Y$$ are exponentialy distributed they are a.s. positive, so $$Y + z > 0$$ therefore part $$P(X \leq Y+z)$$ is fine. On the other hand we must be careful with $$P(X \leq Y-z)$$. Since total probability rule \begin{align} P(X \leq Y-z) & = P(X \leq Y-z |Y \leq z)P(Y\leq z) + P(X \leq Y-z |Y> z)P(Y>z) \\ & = P(X\leq Y-z|Y > z)P(Y>z) \end{align} But what is $$P(X \leq Y-z)$$? It is some number between 0 an 1 dependent only on parameter $$z$$. But it involves two random variables, so just as in one dimensional case where you integrate density over subcpace of real line to get $$P(X \leq z)$$, here we must integrate joint densities of both random variables over some subspace of plane (since $$X$$ and $$Y$$ are independent we can take product of their densities instead). So \begin{align} P(X \leq Y -z) & = \int_z^{\infty} \int_0^{y-z} e^{-y}e^{-x}dx dy \\ & = -\left(\frac{e^{-z}}{2}-e^{-z}\right) \end{align}

In same way, only that we integrate over different region, we get $$P(X \leq Y+z) = -\left(\frac{1}{2}e^{-z}-1\right)$$. Then when you take in account that $$P(Y > z ) = e^{-z}$$ everything else is just elementary computation.

To get PDF you must of course differentiate CDF of $$Z$$ (in fact $$Z$$ must be absolutely continuous but in this, as in most cases, it is). But again CDF and PDF respectively must be functions of only $$z$$.