I have two random variables $X_1$ and $X_2$ where:
$$f_{X_1}(x) = f_{X_2}(x) = \begin{cases} e^{-\frac x2}, \quad \text{if} \; 0 \leq x \leq \mathrm{ln}\: 4\\ 0, \quad \quad \text{otherwise} \end{cases}$$
and a third random variable $Y = X_1 - X_2$. Now I understand that the sum of two independent random variables can found using a convolution so it makes sense that the difference can also be found using a convolution but how?
My PDF looks like this:
and I know that graphically the convolution for $X_1 +X_2$ looks like this:
- First integral from $0$ to the point where red is still inside blue (in this case $t$)
- Then integral from $t-\mathrm{ln}\:4$ to $\mathrm{ln}\:4$
So how does this change once we take the difference and not the sum? Essentially, if flipping and shifting is the convolution sum then what it different when there is a difference that needs to be calculated?
Edit: Based on the answer by perepelart I solved the convolution sum as follows:
to find $Y$ we can start the convolution as follows:
Step 1: First, we flip $f_Z$ and slide it to the point that it starts entering $f_X$. Before this point $f_Y$ is zero.
Here-forth the convolution integral for $-\mathrm{ln}\: 4 \leq t<0$ becomes:
\begin{align*} f_X \ast f_Z &= \int_{-\infty}^{\infty} f_X(x) f_Z(t-x) dx\\ & = \int_{0}^{t+\mathrm{ln}\: 4} f_X(x) f_Z(t-x) dx\\ & = \int_{0}^{t+\mathrm{ln}\: 4} e^{-\frac x2} e^{-\frac{(t-x)}{2}} dx\\ & = (t+\mathrm{ln}\: 4)e^{-\frac t2} \qquad \text{for} \: -\mathrm{ln}\: 4 \leq t<0 \end{align*}
Step 2: In this step the sliding PDF $f_Z$ has began exiting the PDF $f_X$ which looks like this:
which will give us the values for $f_Y$ for $0\leq t\leq\mathrm{ln}\: 4$.
Here-forth the convolution integral for $0<t<\mathrm{ln}\: 4$ becomes:
\begin{align*} f_X \ast f_Z &= \int_{-\infty}^{\infty} f_X(x) f_Z(t-x) dx\\ & = \int_{t}^{\mathrm{ln}\: 4} f_X(x) f_Z(t-x) dx\\ & = \int_{t}^{\mathrm{ln}\: 4} e^{-\frac x2} e^{-\frac{(t-x)}{2}} dx\\ & = -(t-\mathrm{ln}\: 4)e^{-\frac t2} \qquad \text{for} \; 0 \leq t \leq\mathrm{ln}\: 4 \end{align*}
Hence, the PDF of $Y$ is:
$$f_Y(y)= \begin{cases} (y+\mathrm{ln}\: 4)e^{-\frac y2}, \qquad \text{for} \; -\mathrm{ln}\: 4 \leq y<0,\\ -(y-\mathrm{ln}\: 4)e^{-\frac y2}, \quad \; \text{for} \; 0 \leq y \leq \mathrm{ln}\: 4,\\ 0 \qquad \qquad \qquad\qquad \text{otherwise}. \end{cases}$$
The plot of $f_Y(y)$ looks as follows:
Although $f_Y$ is always non-negative it integrates to $2$, hence, it is an invalid PDF.





