# density of sum of two uniform random variables $[0,1]$

I am trying to understand an example from my textbook.

Let's say $Z = X + Y$, where $X$ and $Y$ are uniform random variables with range $[0,1]$. Then the PDF is $$f(z) = \begin{cases} z & \text{for 0 < z < 1} \\ 2-z & \text{for 1 \le z < 2} \\ 0 & \text{otherwise.} \end{cases}$$

For convolution, you want $\int_{-\infty}^\infty f_Y(z-x)f_X(x)\,dx$. So since density is $0$ outside $(0,1)$, we need $0\le z-x\le 1$, or equivalently $x\le z\le x+1$. For $z\le 1$, the first bound is the one to use. For $1\lt z\le 2$, it is the second. –  André Nicolas Apr 11 '13 at 1:33