# Find the density function of the random variable $Z=X+Y$

Let $X$ and $Y$ be independent and uniformly distributed random variable on the intervals $[0,3]$ and $[0,1]$, respectively. Find the density function of the random variable $Z=X+Y$.

I find $f(x,y)=1/3$ and the range of $Z$ to be $[0,4]$, but I cannot find the density function of $Z$.

-
Find $P\{Z \leq \alpha\}$ for $\alpha \in [0,1]$, for $\alpha \in (1,3)$, and $\alpha \in [3,4]$. Then differentiate with respect to $\alpha$ to find the density function. Look, for example, at this question and its answers for ideas on how to proceed. –  Dilip Sarwate Jan 8 '13 at 2:11

In general, to find the pdf, you should find the cdf first, and then differentiate the function.

$F[z] = P(Z \leq z) = \begin{cases} \frac {1}{6} z^2 & 0\leq z \leq 1 \\ \frac {1}{6} + \frac {1}{3} (x-1) & 1 \leq z \leq 3 \\ 1- \frac {1}{6} (4-z)^2 & 3 \leq z \leq 4 \\ \end{cases}$

This gives that

$f(z) = \begin{cases} \frac {1}{3} z & 0 \leq z \leq 1 \\ \frac {1}{3} & 1 \leq z \leq 3 \\ \frac {1}{3} (4-z) & 3 \leq z \leq 4 \\\ \end{cases}$

-
The "hard" part of this problem is determining the CDF and perhaps you could provide some hints to the OP as to how to go about doing that. –  Dilip Sarwate Jan 8 '13 at 12:44

Another way, if you are confortable with convolutions, is to recall that the sum of independent variables has a density that is the convolution of the components. In this case, we must convolve a unit rectangle with a rectangle in $[0,3]$, which is very similar to this image (except for some axis shifting and scaling) (in our case we'd have $f_X$ in red, $f_Y$ in blue, and the result in green), and which results in the function given in Calvin's answer.

-
When one realizes that the result of the convolution is a trapezoid whose base is of length $4$ and the "top" (the side parallel to the base) is of length $2$, very little additional calculation is required. The area of the trapezoid is $$\frac{1}{2}\times(4+2)\times(\text{distance between parallel sides})$$ and since the area must be $1$, we have that $f_Z(z)$ increases linearly from $0$ to $\frac{1}{3}$ as $z$ increases from $0$ to $1$, has constant value $\frac{1}{3}$ for $z\in[1,3]$ and decreases linearly to $0$ as $z$ increases from $3$ to $4$; additional details as in Calvin's answer. –  Dilip Sarwate Jan 8 '13 at 12:55