# Probability function for difference between two i.i.d. Exponential r.v.s

My answer is completely off. Can you please tell me where did my logic go wrong.

Donald Trump and Tori Black are to meet at a specific time and both will be late by $$\sim Exponential(\lambda), i.i.d.$$. What is the cdf of the arrival time difference.

Let $$X, Y$$ be the late time and difference be $$Z = X - Y$$. Cases are $$z \geq 0$$ and $$z < 0$$.

First, for $$z \geq 0$$,

$$F_Z(z) = P(Z\leq z) = P(X-Y \leq z) = 1 - P(X-Y > z) = 1 - P(X>Z+Y)$$

Z $$\geq 0$$, so $$X \geq 0$$ for all $$Y$$.

\begin{align} F_Z(z) & = 1 - \int_0^\infty(\int_{z+y}^\infty f_{X,Y}(x,y)dx) dy \\& = 1 - \int_0^\infty(\int_{z+y}^\infty \lambda e^{-\lambda y}\cdot\lambda e^{-\lambda x}dx) dy \\& = 1 - \int_0^\infty\lambda e^{-\lambda y}(-e^{-\lambda x}|_{z+y}^\infty) dy \\& = 1 - \int_0^\infty\lambda e^{-2\lambda y}e^{-\lambda z}dy \\& = 1 - e^{-\lambda z}\int_0^\infty \lambda e^{-2\lambda y} \\& = 1 - \frac{1}{2}e^{-\lambda z}\end{align}

Now, for $$z < 0$$, where my calculation went very wrong.

Similarly, $$F_Z(z) = 1 - P(X-Y > z) = 1 - P(X>Z+Y)$$

$$Z < 0$$, so for $$X \geq 0$$, $$Y$$ should be $$Y \geq -Z$$, so I do:

\begin{align}F_Z(z) & = 1 - \int_{-z}^\infty(\int_{z+y}^\infty \lambda e^{-\lambda y}\cdot\lambda e^{-\lambda x}dx) dy \\& = 1- \int_{-z}^\infty \lambda e^{-\lambda y}\cdot e^{-\lambda (z+y)}dy \\& = 1 - e^{- \lambda z}\int_{-z}^\infty \lambda e^{-2\lambda y}dy \\& = 1 - e^{-\lambda z}\cdot \frac{1}{2}e ^{2\lambda z} \\& = 1 - \frac{1}{2}e^{\lambda z}.\end{align}

Hence, my answers for both cases are the same except the $$z$$ sign.

The correct CDFs are given in textbook as

$$F_Z(z) = 1 - \frac{1}{2}e^{-\lambda z}$$ for $$z\geq 0$$ and $$\frac{1}{2}e^{\lambda z}$$ for $$z<0$$.

I forgot to integrate $$Y$$ over $$\int_0^{-z}$$ for $$z<0$$, which when included gives the textbook answer.

• In your last line, you have $x$ for $z.$ Perhaps see Wikipedia on Laplace distributions. Aug 18, 2020 at 14:32
• Can’t you just answer ‘Poisson’? Exponential waiting times are distributed Poison. Aug 29, 2020 at 3:32

Your integral limits are not correct. If you draw the region of integration, it'll be in the first quadrant and to the right of the line $$X-Y=z$$. It'll be easier to integrate if the order of integration is $$dy dx$$. Otherwise, you'd need to calculate two different ranges: $$0\leq y \leq -z$$ and $$-z. In your integral, you just calculate the second interval.

\begin{align}P(X>z+Y)&=\int_0^\infty \int_0^{x-z}\lambda e^{-\lambda x}\lambda e^{-\lambda y}dydx\\&=\int_0^\infty \lambda e^{-\lambda x}(1-e^{-\lambda(x-z)})dx\\&=1-e^{\lambda z}\int_0^\infty \lambda e^{-2\lambda x}dx\\&=1-e^{\lambda z}/2\end{align}

This yields $$F_Z(z)=e^{\lambda z}/2$$

• Right! I only integrated $Y$ using $\int_{-z}^\infty$, leaving the part below $-z$ behind. For $Z<0, \int_{-z}^\infty \int_{z+y}^\infty \lambda e^{-\lambda x}\lambda e^{-\lambda y} dxdy + \int_0^{-z} \int_0^\infty \lambda e^{-\lambda x}\lambda e^{-\lambda y} dxdy = \frac{1}{2}e^{\lambda z} + (-e^{\lambda z} + 1)$. Subtracting them from 1, $-\frac{1}{2}e^{\lambda z}+e^{\lambda z} = \frac{1}{2}e^{\lambda z}$ Aug 18, 2020 at 15:44

I will not answer the OP's question as to where his analysis for the case $$z<0$$ went wrong but instead point out an easier way of getting to the correct answer once the value of $$F_Z(z)$$ has been determined to be $$1-\frac 12 \exp(-\lambda z)$$ when $$z > 0$$.

Since $$X$$ and $$Y$$ are i.i.d. random variables, the density of $$Z = X-Y$$ must be the same as the density of $$-Z = Y-X$$, that is, the density must be an even function. One consequence of this is that $$P(Z>\alpha) = P(Z<-\alpha)$$ and so we immediately get \begin{align} P(Z > z) &= \frac 12 \exp(-\lambda z), &z > 0,\\ &{\big \Downarrow}\\ P(Z < -z) &= \frac 12 \exp(-\lambda z), &z > 0,\\ &{\big \Downarrow}\\ P(Z < z) &= \frac 12 \exp(\lambda z), &z < 0,\\ \end{align} and so, $$F_Z(z) = P(Z \leq z) = P(Z < z) = \frac 12 \exp(\lambda z), \,\,\,\ z < 0.$$

• That's what the textbook does. I can 'tell' $Z = X-Y$ is symmetrical such that $-Z =^d Y-X$. $$\\ F_Z(z) = P(Z\leq z) = P(-Z\leq -z) = P(Z\leq -z) = 1-F_Z(-z). \\$$ $z<0$ so $-z>0$, then applying the $F_Z(z)$ for $z\geq 0$ in $1-F_Z(-z)$ will give $F_Z(z)$ for $z<0$. $\\$ Symmetry here is obvious, but issue is I am not sure if I can always tell 'symmetry'. Aug 19, 2020 at 10:07
• @ABC Analytics it is symmetric because $X$ and $Y$ are similarly distributed variables and their roles can be swapped. If the variables would have a different $\lambda$ parameter then it wouldn't work anymore. Oct 1, 2020 at 20:52

In fact, this problem can be solved without computing any integrals at all if you start from the knowledge that the exponential distribution is the only continuous distribution which has no memory. That means if a random variable $$X\sim\text{Expon}(\lambda)$$ then also $$X-a|X>a\sim\text{Expon}(\lambda)$$ for any $$a>0$$. In other words, if $$X$$ is the time until Donald Trump arrives and he has not arrived after, say, 10 minutes, then time until he arrives beyond those 10 minutes is also distributed as $$X$$. This may seem counterintuitive but is easy to prove.

Now if $$X,Y$$ are iid $$\text{Expon}(\lambda)$$ and the arrival time of Donald and Tori respectively, then Donald will be the first to arrive with probability 0.5: $$\text{Prob}(Y>X)=0.5$$. More importantly in that case however, the memoryless property of $$Y$$ tells us that $$Y-X|Y>X \sim\text{Expon}(\lambda)$$ whatever the value of $$X$$ and therefore $$-Z|Y>X$$ is $$\text{Expon}(\lambda)$$. Likewise, if Tori arrives first, with probability $$\text{Prob}[X>Y]=0.5$$, then $$Z|X>Y$$ is also $$\text{Expon}(\lambda)$$. Bringing together the two cases gives you the symmetrical result for $$F_Z(z)$$ that was obtained before.

• You might make this correspond to an integration (which might be necessary if you wish to proof the property of having memory). Then you get $$P(X>z+Y|X>Y) = \int_0^\infty P(X>z+Y|X>Y,Y=y)f_Y(y) dy$$ or $$P(X>z+Y|X>Y) = \int_0^\infty \frac{\int_{z+y}^\infty f_X(x) dx } {\int_{y}^\infty f_X(x) dx }f_Y(y)dy$$ where ratio of integrals is a term independent of y and can be taken outside the integral. This contrasts with $$P(X>z+Y) = \int_0^\infty P(X>z+Y|Y=y)f_Y(y) dy = \int_0^\infty {\int_{z+y}^\infty f_X(x) dx } f_Y(y)dy$$ which does not have that ratio. Oct 1, 2020 at 20:41

I asked for cdf but if it were for pdf.

For $$z\geq 0, 0\leq z\leq x <\infty$$, \begin{align} f_Z(z) &= \int_z^\infty f_X(x)\cdot f_y(x-z)dx \\ & = \lambda^2 e^{\lambda z}\int_z^\infty e^{-2\lambda x}dx \\ &= \frac{\lambda}{2}e^{-\lambda z} \end{align}

For $$z<0, z< 0\leq x <\infty$$, \begin{align} f_Z(z) &= \int_0^\infty f_X(x)\cdot f_y(x-z)dx \\ & = \lambda^2 e^{\lambda z}\int_0^\infty e^{-2\lambda x}dx \\ &= \frac{\lambda}{2}e^{\lambda z} \end{align}