Pdf of sum of exponential random variables

convolutiondensity functionexponential distributionprobability distributionssolution-verification

I am trying to understand the following:

Let $X$ and $Y$ be independent and exponential random variables with parameter $1$, so $f_X(x) =e^{-x} $ and $f_Y(y) =e^{-y} $. Let $Z=X+Y, X<Y$ and $Z=X-Y, X\geq Y$. Determine the pdf of $Z$.

The solution to the exercise first calculates the cdf $F_Z(z)=P(Z\leq z, X<Y)+P(Z\leq z, X\geq Y)$ and then takes its derivative to obtain $f_Z(z)=\frac{e^{-z}}{2}(1+z)$.

This is fine but it is a bit long so I would like to do the exercise by computing the convolution to obtain $f_Z(z)$ directly, so I did: $f_Z(z)=\int_{0}^{z}e^{-x}e^{-(z-x)}dx=ze^{-z}$ for the $X<Y$ part but when doing the $X\geq Y$ part I get $f_Z(z)=\int_{0}^{x}e^{-z-y}e^{-y}dy=\frac{1}{2}(e^{-z}-e^{-z-2x})$ which is wrong.

Could someone please explain to me what I am doing wrong?

Thanks

Best Answer

Note: $X$ and $Y$ are non-negative random variables.

We have $Z=X+Y$ (ie $Y=Z-X$), exactly when $Z>X$, which is only supported when also $X<Z-X$, ie $2X<Z$.

We have $Z=X-Y$ (ie $Y=X-Z$), exactly when $Z\leqslant X$, which isn't further restricted by the support.

Thus we have the support joint pdf for $X$ and $Z$, and this gives the bounds for your integration.

$$\begin{align}f_{X,Z}(x,z) &= f_{X,Y}(x,z-x)\cdot\mathbf 1_{0\leqslant 2x<z}+f_{X,Y}(x,x-z)\cdot\mathbf 1_{0\leqslant z\leqslant x}\\[1ex] &=\mathrm e^{-z}\cdot\mathbf 1_{0\leqslant 2x<z}+\mathrm e^{-2x+z}\cdot\mathbf 1_{0\leqslant z\leqslant x}\\[2ex] f_{Z}(z)&=\left( \int_0^{z/2}\mathrm e^{-z}\mathrm d x+\int_z^\infty \mathrm e^{-2x+z}\mathrm d x\right)\cdot \mathbf 1_{0\leqslant z}\\[1ex]&=\tfrac {z+1}2\mathrm e^{-z}\cdot\mathbf 1_{0\leqslant z}\end{align}$$