Adding Uniform Densities March 17, 2019 Eric Rasmusen \noindent Rasmusen: Dan R. and Catherine M. Dalton Professor, Department of Business Economics and Public Policy, Kelley School of Business, Indiana University. 1309 E. 10th Street, Bloomington, Indiana, 47405-1701. (812) 855-9219. \href{mailto:[email protected]}{ [email protected]}, \url{http://www.rasmusen.org}. This is a rewrite of the excellent but poorly typeset ``Example: Sum of Two Uniform Densities,'' https://www.chem.purdue.edu/courses/chm621/text/stat/funcs/twovar/sum2uniform.htm. I've left out the first example, the standard one of adding two [0,1] random variables that you can find in lots of places. Suppose you want to find the density of the sum $z = x+y$ of two independent uniform random variables with different supports, where $f(x) = 1$ on [0,1] and and $g(y) = .5$ on [0,2]. First, note that $z$ will have the range [0,3], since its smallest value is where $x=y=0$ and its biggest is where $x=1$ and $y=2$. Second, note that probably the density is going to look different over [0,1], [1,2] and [2,3]. Over [0,1], both $x$ and $y$ have positive densities, though $x$ is going to be most important. Over [1,2], $y$ is going to get more important, though of course $x$ still adds on to the effect of $y$. Over [2,3], the importance of $x$ is dwindling. So we'll look for what the density will be on each of these three intervals. Maybe two will turn out the same-- no harm done, then. Note also that the basic idea of a {\bf convolution} and finding the density of the sum is that $$ h(z) = \int f(x) g(z-x)dx. $$ That's because we can think of $h(x+y)$ as being made up of lots of combinations of f(x)g(y), for all the $x$ and $y$ that sum to $z$. To limit it to combinations that sum to $z$, we note that $f(x)g(y) = f(x) g(z-x)$ for those combinations. (We could equally well have used $f(z-y)g(y)$.) An integral is like summing up continuously all the combinations to get the grand total of the density of $h(z)$ for a particular $z$ from all the combinations of $x$ and $y$ such that $x+y=z$. I didn't specify the bounds of integration yet. They will be different for each of our three ranges. For a given range, the bounds have to be set so that $x$ lies inside of [0,1] and $y$ lies inside of [0,2], though we don't need them to vary over their entire ranges. First, consider $z$ in [0,1]. We can make our bounds of integration 0 and $z$. Then $x$ varies from 0 up to 1 (when $z=1$). Also, then $z-x$ can't go negative (which it could if, say, we just specified an upper bound of .9 and z=.1, so $z-x = -.8$.) So we have $$ For \; z \in [0,1], h(z) = \int_0^z f(x) g(z-x)dx = \int_0^z (1) (.5) dx = |_0^z .5x = .5z - .5(0) = z/2. $$ Thus, $h(z)$ starts off looking like a rising triangle density. Second, consider $z$ in [1,2]. We can make our bounds of integration 0 and $1$. Then $x$ varies from 0 up to 1 (when $z=1$). But $y$ is OK too, because $z$ has a minimum value of 1, so $z-x$ can't be any smaller than 0. In addition, $y$ doesn't become too big, because its maximum value if when $z=2$ and $x=0$, so $y = z-x - 2$. So we have $$ For \; z \in [1,2], h(z) = \int_0^1 f(x) g(z-x)dx = \int_0^1 (1) (.5) dx = |_0^1 .5x = .5(1) - .5(0) = 1/2. $$ Thus, $h(z)$ is a flat uniform density in the middle range. We can check this for the extreme values of $z$ and a middle value. \\ When z = 1, the range of x is 0 to 1 and the range of y is 1 to 0.\\ When z = 1.5, the range of x is 0 to 1 and the range of y is 1.5 to 0.5.\\ When z = 2, the range of x is 0 to 1 and the range of y is 2 to 1.\\ It's a bit weird that since $y=z-x$, $y$ has a range from a bigger number to a smaller one as $x$ increases, but writing a range as [0,1] instead of [1,0] is just a convention after all. Third, consider $z$ in [2,3]. We can make our bounds of integration $z-2$ and $1$. How do you come up with those numbers? Well, we want $x$ to be in [0,1], and by varying $z$ we go from z-2=0 to z-2=1. But $y$ is OK too. The minimum value of $z-x$ is going to be where $z=2$ and $x=1$ so $z-x=1.$ The maximum value of $z-x$ is going to be where $z=3$ and $x=1$ so $z-x=2$ or $z=2$ and $x = z-2 =0$ so $z-x=2$. Note that $y$ is not varying all the way from 0 to 2, its entire range. That is fine, even good, because to get $z>2$, we need $y$ to equal at least 1. So we have $$ For \; z \in [2,3], h(z) = \int_{2-z}^1 f(x) g(z-x)dx = \int_{2-z}^1 (1) (.5) dx = |_{2-z}^1 .5x = .5 - (2-z)/2 = z/2 -.5 $$ Thus, $h(z)$ is a downward triangle density for large values of $z$. We can check this for the extreme values of $z$ and a middle value. \\ When z = 2, the range of x is 0 to 1 and the range of y is 2 to 1.\\ When z = 2.5, the range of x is 0.5 to 1 and the range of y is 2 to 1.5.\\ When z = 3, the range of x is 1 to 1 and the range of y is 2 to 2. The convolution of two uniform pdfs having different ranges of the random variable generates a symmetric trapezoid. The trapezoid's base will equal to the sum of the ranges. The top of the trapezoid will equal to the difference between the ranges of $x$ and $y$, with a height of $|f(x) - g(y)|$. The two slants, the up-ramp and down-ramp, will each have a length equalt to the range of the more constricted of the two variables we are summing. It might be good to check that we actually have a density that integrates to 1. A nice low-tech way to do that is to calculate the area of the two triangles and the rectangle that make up the density. Each triangle has area .5(1)(.5)= .25 each. The rectangle has areas (1)(.5) =.5. Thus, the areas do sum up to 1.