I have the following exam problem with the solution:
Let $X, Y ∼ U(2, 5)$ be independent random variables. Determine the density function of $Z = X + Y − 2$.
Solution: $\begin{cases}\frac19(z-2)& 2<z<5\\ \frac19(8-z)&5<z<8\\ 0& \text{otherwise}\end{cases}$
I've tried the following: Since $X, Y \in [2, 5]$, then $Z \in [2, 8]$ .
$P(Z < z) = ? = P(X + Y - 2 < z) = P(X + Y < z + 2) = \int_{-\infty}^\infty f_X(x)*f_Y(t-y)dx$ which is the convolution for $f_{X+Y}(t)$.
I get it so far, but it's not clear where we get the two cases of $2 < z < 5$ and $5 < z < 8$ from, so I'd like some help with this part.
Thanks in advance :)
First we compute the density of $W=X+Y$. Because $X$ and $Y$ take take values in $[2,5]$, it is clear that $W$ takes values in $[4,10]$. The density is given by the convolution integral: $$ f_W(t) = \int_{\mathbb R}f_X(\tau)f_Y(t-\tau)\ \mathsf d\tau, $$ where $f_X(\tau) = \frac13\cdot\mathsf1_{(2,5)}(\tau)$ and $f_Y(t-\tau)=\frac13\cdot\mathsf1_{(2,5)}(t-\tau)$. There are two cases to consider. When $4<t<7$ we have $$ f_W(t) = \int_4^t \frac19\ \mathsf d\tau = \frac 19(t-4). $$ When $7<t<10$ we have $$f_W(t) = \int_t^{10} \frac19\ \mathsf d\tau = \frac 19(10-t).$$ Now, since $Z = W-2$, it is clear that $Z$ takes values on $[2,8]$ and has the density of $W$ shifted to the left by $2$: $$ f_Z(z) = \frac19\ \mathsf d\tau = \frac 19(z-2)\cdot\mathsf1_{(2,5)} + \frac19\ \mathsf d\tau = \frac 19(8-z)\cdot\mathsf1_{(5,8)}. $$