Convolution of distributions defined on a particular interval Suppose you have a random variable $Z=X_1+X_2$, where $X_1$ and $X_2$ are distributed identically with the following probability distribution function (pdf):
$$
p(X_i=x)=
\begin{cases}
    1-\frac{x}{2},& \text{if } 0\leq x\leq 2;\\
    0,              & \text{otherwise.}
\end{cases}
$$
If I wanted to convolve these two distributions, I thought I could just take the integral
$$p(Z=z)=\int_0^2{\left(1-\frac{z-t}{2}\right)\left(1-\frac{t}{2}\right)dt}$$
but that integral evaluates to $\frac{4}{3}-\frac{x}{2}$. Since $Z$ should be valid on the interval $0\le Z \le 4$ the pdf would look like:

However, this doesn't make any sense. The pdf should never be negative. I've tried different bounds of integration, etc., with no luck. What am I missing here?
 A: If $f(x)$ is the pdf of $X_1$ and $X_2$, then the convolution is
$$ f_Z(z)=\int_{-\infty}^{\infty}f(z-t)f(t)\;dt=\int_0^2f(z-t)f(t)\;dt $$
since $f(t)$ is zero if $t<0$ or $t>2$.
However, you also have to take this fact into account for $f(z-t)$. For instance, if $z=1$ then the requirement $z-t\geq 0$ implies that we must have $t\leq 1$ in the integral. Similarly, if $z=3$ then $z-t\leq 2$ implies that $t\geq 1$. So you need to be more careful with your bounds before substituting in the definition of $f$.
A: Okay, I figured it out thanks to the answer by carmichael561. 
I knew I had to do something about changing bounds of integration, but was getting confused on how to do so. The trick is you have to split the function for $p(z)$ into two different convolutions:
$$p(z) = 
\begin{cases}
    \int_0^z{p(z-t)p(t)} = z-\frac{z^2}{2}+\frac{z^3}{24},& \text{for } 0\leq z\leq 2\\
    \int_{z-2}^2{p(z-t)p(t)} = \frac{8}{3}-2z-\frac{z^2}{2}+\frac{z^3}{24},              & \text{for } 2\le z\le 4
\end{cases}
$$
it's easy to check that these are a good probability distribution as their integral adds to 1:

Also, the probability distribution is continuous:

Here is an image of the probability distribution:

