Expectation of the difference of two exponential random variables.

absolute valueconvolutionexponential distributionprobability distributionsrandom variables

Let $X, Y$ be independent random variables exponentially distributed with parameter 1. Find the $E(|X-Y|)$.

My approach :

Let $Z = X – Y $. Then, the goal is to find $E(|Z|) = \int_{-\infty}^{\infty}{|z|f_Z(z)dz}$. So, in order to find the density for $Z$, I use a convolution method:

$$ F_Z(z) = P(Z \leq z) = P(X – Y \leq z) = \iint_{X-Y \leq z}{f_X(x)f_Y(y)dxdy} = \int_{-\infty}^{\infty}\int_{-\infty}^{z+y}{f_X(x)f_Y(y)dxdy} = \int_{-\infty}^{\infty}F_X(z+y)f_Y(y)dy$$

Now, differentiating with respect to z, we can get the density of z.

$$ \frac{d}{dz}\left(F_Z(z)\right) = f_Z(z) = \int_{-\infty}^{\infty}{f_X(z+y)f_Y(y)dy} $$

Since X, Y are $\sim Exp(1)$, their densities are known and the integral simplifies to:

$$ f_Z(z) = \int_{0}^{\infty}{e^{-z}e^{-2y}dy} = -\frac{1}{2}e^{-z} $$

Then, the expectation value is:

$$ E(|Z|) = \int_{-\infty}^{\infty}{-\frac{1}{2}|z|e^{-z}dz} = \int_{-\infty}^{0}{\frac{1}{2}ze^{-z}dz} + \int_{0}^{\infty}{-\frac{1}{2}ze^{-z}dz} $$

I thought that this was correct, but I am confused on the bounds of Z since evaluating this integral from $-\infty$ makes the expression divergent.

Is it the case that since $z \geq 0$, then the integral for the expectation value simplifies to:

$$ E(|Z|) = \int_{-\infty}^{\infty}{-\frac{1}{2}|z|e^{-z}dz} = \int_{0}^{\infty}{-\frac{1}{2}ze^{-z}dz} $$ ?

Best Answer

The issue is in your computation of $f_z$, as you do not write the indicator functions: the density of $Y$ is not $e^{-y} \: \mathrm{d} y$, but $e^{-y} 1_{\{y > 0\}} \: \mathrm{d} y$. Therefore, your integral becomes, \begin{align*} F_z(z) & = \int_{- \infty}^{+\infty} f_X(z+y) f_Y(y) \: \mathrm{d} y \\ & = \int_{- \infty}^{+\infty} e^{-(z+y)} 1_{\{z+y>0\}} e^{-y} 1_{\{y>0\}} \: \mathrm{d} y \\ & = e^{-z} \int_{- \infty}^{+\infty} e^{-2y} 1_{\{y>-z\}} 1_{\{y>0\}} \: \mathrm{d} y. \end{align*} If $z \geq 0$ then the integral is $$ \int_0^{+\infty} e^{-2y} \: \mathrm{d} y = \frac12, $$ (you made a sign mistake here, btw), while if $z < 0$, it is $$ \int_{-z}^{+\infty} e^{-2y} \: \mathrm{d} y = \frac12 e^{2z}. $$ Finally, the density of $Z$ is $$ f_z(z) = \frac12 \left ( e^{-z} 1_{\{z \geq 0\}} + e^{z} 1_{\{z < 0\}} \right) $$ Then, you readily get that $$ \mathbb{E}(Z) = \frac12+\frac12 = 1. $$