# Difference of two exponential distribution

Let $$X\sim Exp(\lambda_1)$$ and $$Y\sim Exp(\lambda_2)$$, with $$Z = X - Y$$.

I am trying to find the pdf of Z, i.e. $$f_Z(z)$$.

Here is what I have got:

\begin{align*} f_Z(z) &= \int_0^{z}f_X(z+y)f_Y(y)dy\\ &= \int_0^{z}\lambda_1 e^{-\lambda_1(z+y)}\lambda_2 e^{-\lambda_2y}dy\\ &= \lambda_1\lambda_2e^{-\lambda_1z}\int_0^{z}e^{-(\lambda_1+\lambda_2)y}dy\\ &= \lambda_1\lambda_2e^{-\lambda_1z}\bigg[\frac{e^{-(\lambda_1+\lambda_2)y}}{-(\lambda_1+\lambda_2)}\bigg]_{y=0}^{y=z}\\ &= \frac{\lambda_1\lambda_2e^{-\lambda_1z}}{\lambda_1+\lambda_2}(1 - e^{-{(\lambda_1 + \lambda_2)}z})\\ &= \frac{\lambda_1\lambda_2}{\lambda_1+\lambda_2}(e^{-\lambda_1z} - e^{-{(2\lambda_1 + \lambda_2)}z}) \end{align*}

But I have looked at other page from mathstackexchange, pdf of the difference of two exponentially distributed random variables, but I cannot get that answer.

Edit: $$X$$ and $$Y$$ are independent.

• You are forgetting a crucial assumption: independence of $X$ and $Y$. Further you are forgetting that $X-Y$ is not a positive random variable. You have to consider negative values of $z$ as well. – Kavi Rama Murthy Mar 15 at 23:35
• So should the integral be $\int_{-\infty}^{z}f_X(z+y)f_Y(y)dy$, or do I need to do it by using the one was done like the other page? – VincentN Mar 16 at 0:36

## 1 Answer

$$\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,} \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace} \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack} \newcommand{\dd}{\mathrm{d}} \newcommand{\ds}[1]{\displaystyle{#1}} \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,} \newcommand{\ic}{\mathrm{i}} \newcommand{\mc}[1]{\mathcal{#1}} \newcommand{\mrm}[1]{\mathrm{#1}} \newcommand{\pars}[1]{\left(\,{#1}\,\right)} \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,} \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}} \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$$ \begin{align} \mrm{f}_{Z}\pars{z} & = \int_{0}^{\infty}\mrm{f}_{X}\pars{z + y}\mrm{f}_{Y}\pars{y} \bracks{z + y > 0}\dd y \\[5mm] & = \int_{0}^{\infty}\lambda_{1}\expo{-\lambda_{1}\pars{z + y}} \lambda_{2}\expo{-\lambda_{2}y}\bracks{y > -z}\dd y \\[5mm] & = \lambda_{1}\lambda_{2}\expo{-\lambda_{1}z} \int_{0}^{\infty}\expo{-\pars{\lambda_{1} + \lambda_{2}}y} \bracks{y > - z}\dd y \\[8mm] & = \lambda_{1}\lambda_{2}\expo{-\lambda_{1}z}\left\{% \bracks{z < 0}\int_{-z}^{\infty}\expo{-\pars{\lambda_{1} + \lambda_{2}}y}\dd y\right. \\[2mm] & \phantom{= \lambda_{1}\lambda_{2}\expo{-\lambda_{1}z}\,\,\,} \left.\mbox{} + \bracks{z > 0}\int_{0}^{\infty} \expo{-\pars{\lambda_{1} + \lambda_{2}}y}\dd y\right\} \\[8mm] & = \lambda_{1}\lambda_{2}\expo{-\lambda_{1}z}\bracks{% \bracks{z < 0}{\expo{\pars{\lambda_{1} + \lambda_{2}}z} \over \lambda_{1} + \lambda_{2}} + \bracks{z > 0}{1 \over \lambda_{1} + \lambda_{2}}} \\[5mm] & = \bbx{{\lambda_{1}\lambda_{2} \over \lambda_{1} + \lambda_{2}}\braces{\bracks{z < 0}\,\expo{\lambda_{2}z} + \bracks{z > 0}\expo{-\lambda_{1}z}}} \end{align}

• Thanks a lot for your help! – VincentN Mar 16 at 20:19
• @VincentN You're welcome. – Felix Marin Mar 17 at 4:43