# 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
