# Pdf of the sum of two independent Uniform R.V., but not identical

Question. Suppose $$X \sim U([1,3])$$ and $$Y \sim U([1,2] \cup [4,5])$$ are two independent random variables (but obviously not identically distributed). Find the pdf of $$X + Y$$.

So far. I'm familiar with the theoretical mechanics to set up a solution. So, if we let $$\lambda$$ be the Lebesgue measure and notice that $$[1,2]$$ and $$[4,5]$$ disjoint, then the pdfs are

$$f_X(x) = \begin{cases} \frac{1}{2}, &x \in [1,3] \\ 0, &\text{otherwise} \end{cases} \quad\text{and}\quad f_Y(y) = \begin{cases} \frac{1}{\lambda([1,2] \cup [4,5])} = \frac{1}{1 + 1} = \frac{1}{2}, &y \in [1,2] \cup [4,5] \\ 0, &\text{otherwise} \end{cases}$$

Now, let $$Z = X + Y$$. Then, the pdf of $$Z$$ is the following convolution $$f_Z(t) = \int_{-\infty}^{\infty}f_X(x)f_Y(t - x)dx = \int_{-\infty}^{\infty}f_X(t -y)f_Y(y)dy.$$

To me, the latter integral seems like the better choice to use. So, we have that $$f_X(t -y)f_Y(y)$$ is either $$0$$ or $$\frac{1}{4}$$. But I'm having some difficulty on choosing my bounds of integration?

• If you draw a suitable picture, the pdf should be instantly obvious ... and you'll also get relevant information about what the bounds would be for the integration Sep 26 '20 at 6:13
• Does this answer your question? general solution sum of two uniform random variables aY+bX=Z? Sep 26 '20 at 7:18
• I find it convenient to conceive of $Y$ as being a mixture (with equal weights) of $Y_1,$ a Uniform$(1,2)$ distribution, and $Y_,$ a Uniform$(4,5)$ distribution. Thus $X+Y$ is an equally weighted mixture of $X+Y_1$ and $X+Y_2.$
– whuber
Sep 26 '20 at 16:50
• I was hoping for perhaps a cleaner method than strictly plotting. Consider if the problem was $X \sim U([1,5])$ and $Y \sim U([1,2] \cup [4,5] \cup [7,8] \cup [10, 11])$. It becomes a bit cumbersome to draw now. Using the comment by @whuber, I believe I arrived at a more efficient method to reach the solution. Sep 26 '20 at 21:29

Here is a plot as suggested by comments

What I was getting at is it is a bit cumbersome to draw a picture for problems where we have disjoint intervals (see my comment above). It's not bad here, but perhaps we had $$X \sim U([1,5])$$ and $$Y \sim U([1,2] \cup [4,5] \cup [7,8] \cup [10, 11])$$.

Using @whuber idea: We notice that the parallelogram from $$[4,5]$$ is just a translation of the one from $$[1,2]$$. So, if we let $$Y_1 \sim U([1,2])$$, then we find that

$$f_{X+Y_1}(z) = \begin{cases} \frac{1}{4}z - \frac{1}{2}, &z \in (2,3) \tag{\dagger}\\ \frac{1}{2}z - \frac{3}{2}, &z \in (3,4)\\ \frac{5}{4} - \frac{1}{4}z, &z \in (4,5)\\ 0, &\text{otherwise} \end{cases}$$

Since, $$Y_2 \sim U([4,5])$$ is a translation of $$Y_1$$, take each case in $$(\dagger)$$ and add 3 to any constant term. Then you arrive at ($$\star$$) below.

Brute force way:

• $$\mathbf{2 < z < 3}$$: $$y=1$$ to $$y = z-1$$, which gives $$\frac{1}{4}z - \frac{1}{2}$$.
• $$\mathbf{3 < z < 4}$$: $$y=1$$ to $$y = z-1$$, such that $$2\int_1^{z-1}\frac{1}{4}dy = \frac{1}{2}z - \frac{3}{2}$$.
• $$\mathbf{4 < z < 5}$$: $$y=z-3$$ to $$y=2$$, which gives $$\frac{5}{4} - \frac{1}{4}z$$.
• $$\mathbf{5 < z < 6}$$: $$y=4$$ to $$y = z-1$$, which gives $$\frac{1}{4}z - \frac{5}{4}$$.
• $$\mathbf{6 < z < 7}$$: $$y = 4$$ to $$y = z-2$$, such that $$2\int_4^{z-2}\frac{1}{4}dy = \frac{1}{2}z - 3$$.
• $$\mathbf{7 < z < 8}$$: $$y = z-3$$ to $$y=5$$, which gives $$2 - \frac{1}{4}z$$.

Therefore,

$$f_Z(z) = \begin{cases} \frac{1}{4}z - \frac{1}{2}, &z \in (2,3) \tag{\star}\\ \frac{1}{2}z - \frac{3}{2}, &z \in (3,4)\\ \frac{5}{4} - \frac{1}{4}z, &z \in (4,5)\\ \frac{1}{4}z - \frac{5}{4}, &z \in (5,6)\\ \frac{1}{2}z - 3, &z \in (6,7)\\ 2 - \frac{1}{4}z, &z \in (7,8)\\ 0, &\text{otherwise} \end{cases}$$

• +1 For more methods of solving this problem, see stats.stackexchange.com/a/43075/919.
– whuber
Sep 26 '20 at 21:31
• Thank you for the link! It's too bad there isn't a sticky section, which contains questions that contain answers that go above and beyond what's required (like yours in the link). Sep 26 '20 at 21:42