# If $X$ and $Y$ are i.i.d. with $X\thicksim\text{Exp}(1)$, find $P(Y\geq X\geq2)$, and the PDF of $Z=X-Y$

The Problem: Let $$X$$ and $$Y$$ be independent exponential random variables with parameter $$\lambda=1$$.
$$\textbf{a)}$$ Calculate the probability $$P(Y\geq X\geq2)$$.
$$\textbf{b)}$$ Find the density function of the random variable $$Z=X-Y.$$

My Attempt:
a) By hypothesis, we have that the density functions of $$X$$ and $$Y$$, respectively, are given by $$f_X(x)=\begin{cases}e^{-x}&\text{if }x\geq0\\0&\text{otherwise.}\end{cases}\quad f_Y(y)=\begin{cases}e^{-y}&\text{if }y\geq0\\0&\text{otherwise.}\end{cases}$$ Since $$X$$ and $$Y$$ are independent, it follows that $$f_{XY}(x,y)=f_X(x)\cdot f_Y(y)=\begin{cases}e^{-(x+y)}&\text{if }x\geq0,\,y\geq0\\0&\text{otherwise.}\end{cases}$$ Now to find the probability in question we integrate the joint density function over the region $$D=\{(x,y)\in\mathbb R^2:2\leq x\leq y\}.$$ We have \begin{align} P(Y\geq X\geq2)&=\iint_D f_{XY}(x,y)\,dy\,dx=\int_2^\infty\int_x^\infty e^{-(x+y)}\,dy\,dx\\ &=\int_2^\infty e^{-2x}\,dx\\ &=\frac{1}{2e^4}. \end{align} b) We can first find the CDF of $$Z$$ using the joint PDF of $$X$$ and $$Y$$ by integrating the latter function over the region $$D=\{(x,y)\in\mathbb R^2:x-y\leq t\}$$ where $$t\in\mathbb R.$$ If $$t\leq0$$, then \begin{align*} P(X-Y\leq t)&=\iint_D f_{XY}(x,y)\,dy\,dx=\int_0^\infty\int_{x-t}^\infty e^{-(x+y)}\,dy\,dx\\ &=e^t\int_0^\infty e^{-2x}\,dx\\ &=\frac{e^t}{2}. \end{align*} On the other hand, if $$t>0$$, then \begin{align*} P(X-Y\leq t)&=\iint_D f_{XY}(x,y)\,dy\,dx\\&=\int_0^t\int_0^\infty e^{-(x+y)}\,dy\,dx+\int_t^\infty\int_{x-t}^\infty e^{-(x+y)}\,dy\,dx\\ &=\int_0^t e^{-x}\,dx+\int_t^\infty e^t e^{-2x}\,dx\\ &=1-e^{-t}+\frac{e^{-t}}{2}\\ &=1-\frac{e^{-t}}{2}. \end{align*} Therefore, we have the following case-defined function as the CDF of $$Z$$, $$F_Z(t)=\begin{cases}\dfrac{e^t}{2}&\text{if }t\leq0\\[0.8em]1-\dfrac{e^{-t}}{2}&\text{if }t>0.\end{cases}$$ Since the CDF above is continuous everywhere and differentiable almost everywhere, we can differentiate it to find the PDF. We have $$f_Z(t)=\begin{cases}\dfrac{e^t}{2}&\text{if }t\leq0\\[0.8em]\dfrac{e^{-t}}{2}&\text{if }t>0.\end{cases}$$

Do you agree with my approach and execution above?
Thank you very much for your time and I sincerely appreciate any feedback.

• everything is correct but you wrote wrongly the definition of the regions $D$ because $(x,y)\in[0,\infty)^2$ instead of $\mathbb{R}^2$ but the calculations seems fine – Masacroso Jul 15 '20 at 19:39

More generally, let $$X\sim\mathrm{Expo}(\lambda)$$ and $$Y\sim\mathrm{Expo}(\mu)$$ be independent and let $$t>0$$ be arbitrary. Then \begin{align} \mathbb P(Y\geqslant X\geqslant t) &= \int_{(t,\infty)\times(t,y)}f_{X,Y}(x,y)\ \mathsf d(x\times y)\\ &=\int_t^\infty \int_t^y \lambda e^{-\lambda x}\mu e^{-\mu y}\ \mathsf dx\ \mathsf dy\\ &= \frac{\lambda }{\lambda +\mu } e^{-(\lambda +\mu )t}. \end{align} Also, note that $$\{Y\geqslant X\geqslant t\} = \{Y\geqslant X\}\cap\{X\wedge Y\geqslant t\},$$ and hence \begin{align} \mathbb P(Y\geqslant X\geqslant t) &= \mathbb P(Y\geqslant T)\mathbb P(X\wedge Y\geqslant T)\\ &= \frac{\lambda }{\lambda +\mu } e^{-(\lambda +\mu )t}. \end{align} Substituting $$\lambda=\mu=1$$ and $$t=2$$ yields $$\frac12 e^{-4}$$, the same as your result.
To compute the density of $$Z=X-Y$$, we use convolution. First note that the density of $$-Y$$ is $$f_{-Y}(y) = \mu e^{\mu y}\cdot\mathsf 1_{(-\infty,0)}$$. Then for $$t\in\mathbb R$$ we have \begin{align} f_Z(t) &= f_X\star f_{-Y}(t)\\ &= \int_{\mathbb R} f_X(s)f_{-Y}(t-s)\ \mathsf ds\\ &= \int_{t\vee 0}^\infty \lambda e^{-\lambda s}\mu e^{\mu(t-s)}\ \mathsf ds\\ &= \frac{\lambda \mu }{\lambda +\mu }\left(e^{\mu t}\cdot\mathsf 1_{(-\infty,0)}(t)+e^{-\lambda t}\cdot\mathsf 1_{[0,\infty)}(t) \right). \end{align} Substituting $$\lambda=\mu=1$$ yields $$f_Z(t) = \frac12\left(e^t\cdot\mathsf 1_{(-\infty,0)} + e^{-t}\mathsf 1_{[0,\infty)}(t)\right),$$ the same as your result. In this case, $$Z$$ has a Laplace distribution.