# Probability Density of the Sum of Two Un-identical Uniform Random Variables

Let $$X$$ ~ Uniform$$[a,b]$$ and $$Y$$ ~ Uniform$$[c,d],$$ where $$a\le b\le c\le d.$$ Find the probability density of $$Z = X + Y.$$

I know I have to use the convolution formula

$$f_Z(z) = \int_{-\infty}^\infty f_X(z-y)f_Y(y)\,\mathrm dy.$$

However, I am struggling to find the region I must integrate over. I know for $$z \le a+c$$ and $$z \gt b+d$$ that $$f_Z(z) = 0.$$ But for the middle terms I do not know what to do. Any help is appreciated.

• It may be worth also breaking the integration at $z=a+d$ and at $z=b+c$ (which might be in either order) Jul 24, 2023 at 7:43
• I'm sorry, but could you explain what you might mean by "middle terms"? The region of integration is always the entire set of real numbers; there are no exceptions. In this case you perform the integration by recognizing that $f_X$ is zero outside the interval $[a,b]$ and $f_Y$ is zero outside $[c,d].$
– whuber
Jul 24, 2023 at 13:13
• BTW, if you would draw a picture of the support of $(X,Y)$ and some contour lines of the function $X+Y,$ you can (literally) read the answer off that diagram. No calculation (not even any algebra) is needed at all.
– whuber
Jul 24, 2023 at 14:06

Plot the contours (level curves) of the function $$(x,y)\to x+y$$ over the support of this distribution.

Here, to illustrate, is such a diagram with $$(a,b)=(0,2)$$ and $$(c,d)=(3,4):$$

The value of $$z=x+y$$ ranges from $$a+c$$ to $$b+d$$ as you sweep from the lower left to upper right (the direction given by the vector $$(1,1),$$ since $$x+y = (x,y)\cdot (1,1)^\prime$$). As it does so, since the distribution of $$(x,y)$$ is uniform, the lengths of the contours are proportional to the probability density of $$z.$$

The diagram makes it clear that those lengths:

• (Region I) Increase linearly from $$0$$ as $$z$$ goes from $$a+c$$ (in the lower left corner) to $$a+d$$ (in the upper left corner),

• (Region II) then remain constant as $$z$$ goes from $$a+d$$ to $$b+c,$$

• (Region III) then decrease linearly to $$0$$ until $$z$$ reaches $$b+d$$ (in the upper right corner).

This description would change slightly were the rectangle vertically oriented (the order of $$a+d$$ and $$b+c$$ gets reversed), but the pattern remains the same. Consequently, $$z$$ has a trapezoidal distribution and we can plot its density function without further ado:

We don't need to label the vertical axis because the total area must be $$1.$$ In this diagram that implies the height of the trapezoid is $$1/(b-a).$$ You can easily write down equations for the five parts of this graph (over the intervals delimited by $$-\infty, a+b, a+d, b+c, b+d,$$ and $$+\infty$$) from this information.

This graphical solution will guide you in articulating a formal answer in terms of integrals.