Tutorials › Statistical Theory I - Probability and Distribution Theory › Sums of Uniform Variables and Piecewise Densities

Many-to-One Transformations · Tutorial 429 of 994

Sums of Uniform Variables and Piecewise Densities

Learn how overlap lengths produce the triangular density and how integrating it gives the piecewise quadratic density for three uniform variables.

Intermediate 9 min read

What You'll Learn

  • Derive the density of the sum of two independent Uniform(0,1) variables.
  • Identify how the support of a sum divides into different density pieces.
  • Derive the piecewise quadratic density for the sum of three independent Uniform(0,1) variables.
  • Check the densities using symmetry, continuity, support, and total probability.
  • Calculate probabilities from the piecewise densities and apply a linear rescaling.

Why Uniform Sums Have Piecewise Densities

A uniform density is flat, but the density of a sum of uniform variables need not be. For two variables, values near the middle of the possible range can be formed in more ways than values near either endpoint. For three variables, the same changing overlap produces a piecewise quadratic density. These examples make the geometry of sum distributions especially visible.

Let \(U_1,U_2,\ldots\) be independent random variables, each with the Uniform(0,1) distribution. Their joint density is constant on the unit square or cube and zero elsewhere. The density of a sum is determined by how much of that square or cube contributes at each possible sum. Here we derive the two-variable and three-variable densities and use their pieces to calculate probabilities.

Definition: A random variable \(U\) has the Uniform(0,1) distribution if its density is \(f_U(u)=1\) for \(0<u<1\) and \(f_U(u)=0\) outside \([0,1]\). For independent \(U_1,\ldots,U_m\), write \(S_m=U_1+\cdots+U_m\). The support of \(S_m\) is \([0,m]\): each summand lies between 0 and 1, and sums throughout that interval are possible.

For independent variables with densities, the density of their sum is the convolution of those densities. In the cases below, if \(X\) has density \(f_X\) and \(U\) is an independent Uniform(0,1) variable, this formula becomes

$$ f_{X+U}(s)=\int_0^1 f_X(s-u)\,du =\int_{s-1}^{s} f_X(v)\,dv, $$

where the integrand is understood to be zero outside the support of \(X\). The second expression follows by setting \(v=s-u\). Thus the integral only counts the part of the interval \([s-1,s]\) that overlaps the support of \(X\). Equivalently, in the first expression only \(u\) values for which \(s-u\) is in that support contribute.

Two Uniform Variables: The Triangular Density

Set \(S_2=U_1+U_2\). For a fixed sum \(s\), the eligible values of \(u=U_1\) must satisfy both \(0\leq u\leq1\) and \(0\leq s-u\leq1\). These inequalities give \( \max(0,s-1)\leq u\leq\min(1,s) \). Because both input densities equal 1 on \([0,1]\), the convolution integral is the length of this interval. Its endpoints change at \(s=1\), which is why the density has two pieces.

Theorem: If \(U_1\) and \(U_2\) are independent Uniform(0,1) random variables, the density of \(S_2=U_1+U_2\) is
$$ f_{S_2}(s)= \begin{cases} s, & 0\leq s\leq1,\\ 2-s, & 1<s\leq2,\\ 0, & \text{otherwise}. \end{cases} $$
The choices of density value at individual endpoints do not affect the distribution.

To derive the formula directly, intersect the eligible interval for \(u\) with \([0,1]\). If \(0<s<1\), the eligible interval is \([0,s]\), of length \(s\). If \(1<s<2\), it is \([s-1,1]\), of length \(2-s\). For \(s<0\) or \(s>2\), there are no eligible values. This proves the stated density almost everywhere, which is sufficient because densities that differ only on a set of probability zero describe the same distribution. \(\square\)

The density rises linearly from 0 to 1, then falls linearly back to 0. This is the triangular density. Its total integral is 1:

$$ \int_0^1 s\,ds+\int_1^2(2-s)\,ds =\frac12+\frac12=1. $$

The two pieces also reflect the symmetry of the sum: replacing each \(U_i\) by \(1-U_i\) changes \(S_2\) to \(2-S_2\), so the density is symmetric around 1.

Worked Example: A Probability From the Triangular Density

Find \(P(S_2\leq0.6)\) for the sum of two independent Uniform(0,1) variables.

Since \(0.6\) is in the first density piece, \(f_{S_2}(s)=s\) for \(0\leq s\leq0.6\). Integrating that density gives

$$ P(S_2\leq0.6) =\int_0^{0.6}s\,ds =\left[\frac{s^2}{2}\right]_0^{0.6} =\frac{0.36}{2} =0.18. $$

As a check, this probability is less than \(P(S_2\leq1)=1/2\), as expected from the symmetry about 1. It is also not \(0.6\): the sum is not itself Uniform(0,2), since its density is not constant.

Three Uniform Variables: The Piecewise Quadratic Density

Now let \(S_3=U_1+U_2+U_3\). We can obtain its density by adding one more independent Uniform(0,1) variable to \(S_2\). The convolution integral is

$$ f_{S_3}(s)=\int_0^1 f_{S_2}(s-u)\,du =\int_{\max(0,s-2)}^{\min(1,s)}f_{S_2}(s-u)\,du, $$

where the second integral includes only the values for which \(s-u\in[0,2]\). The integration limits change at \(s=1\) and \(s=2\). Within the middle region, the integrand itself changes formula when \(s-u=1\), so that region must be split as well.

Theorem: If \(U_1,U_2,U_3\) are independent Uniform(0,1) random variables, the density of \(S_3=U_1+U_2+U_3\) is
$$ f_{S_3}(s)= \begin{cases} \dfrac{s^2}{2}, & 0\leq s\leq1,\\[4pt] -s^2+3s-\dfrac32, & 1<s\leq2,\\[4pt] \dfrac{(3-s)^2}{2}, & 2<s\leq3,\\[4pt] 0, & \text{otherwise}. \end{cases} $$

Here is the full calculation. For \(0<s<1\), the integration range is \(0\leq u\leq s\). Throughout this range \(0\leq s-u\leq1\), so \(f_{S_2}(s-u)=s-u\). Therefore,

$$ f_{S_3}(s)=\int_0^s(s-u)\,du =\left[su-\frac{u^2}{2}\right]_0^s =\frac{s^2}{2}. $$

For \(1<s<2\), the integration range is \(0\leq u\leq1\). When \(0\leq u\leq s-1\), \(s-u\geq1\), so the second piece of \(f_{S_2}\) applies. When \(s-1\leq u\leq1\), \(s-u\leq1\), so the first piece applies. Thus

$$ \begin{aligned} f_{S_3}(s) &=\int_0^{s-1}\bigl(2-(s-u)\bigr)\,du +\int_{s-1}^{1}(s-u)\,du\\ &=\int_0^{s-1}(2-s+u)\,du +\int_{s-1}^{1}(s-u)\,du\\ &=(2-s)(s-1)+\frac{(s-1)^2}{2} +s-\frac12-s(s-1)+\frac{(s-1)^2}{2}\\ &=-s^2+3s-\frac32. \end{aligned} $$

Finally, if \(2<s<3\), the integration range is \(s-2\leq u\leq1\). Here \(1\leq s-u\leq2\), so the second piece of \(f_{S_2}\) applies throughout:

$$ \begin{aligned} f_{S_3}(s) &=\int_{s-2}^{1}\bigl(2-(s-u)\bigr)\,du\\ &=\int_{s-2}^{1}(2-s+u)\,du\\ &=2-s+\frac12+\frac{(s-2)^2}{2}\\ &=\frac{(3-s)^2}{2}. \end{aligned} $$

Outside \([0,3]\) there are no possible sums. The expressions agree at the breakpoints: both adjacent pieces equal \(1/2\) at \(s=1\), and both equal \(1/2\) at \(s=2\). This completes the derivation. \(\square\)

Checks and Worked Probabilities

A piecewise formula should be checked against the support and total probability, not just obtained algebraically. The three-variable density is nonnegative on each piece: on \(1\leq s\leq2\), its middle expression can be written as \( \frac34-(s-\frac32)^2 \), which ranges from \(1/2\) to \(3/4\). Its total integral is

$$ \int_0^1\frac{s^2}{2}\,ds +\int_1^2\left(-s^2+3s-\frac32\right)ds +\int_2^3\frac{(3-s)^2}{2}\,ds =\frac16+\frac23+\frac16=1. $$

The first and last pieces are mirror images around \(s=3/2\), as expected: replacing each \(U_i\) by \(1-U_i\) changes \(S_3\) to \(3-S_3\). These checks are useful for catching an incorrect sign or a missing piece.

Worked Example: Probability That the Three-Variable Sum Is Between One and Two

Calculate \(P(1<S_3<2)\).

On this interval, use the middle density piece and integrate:

$$ \begin{aligned} P(1<S_3<2) &=\int_1^2\left(-s^2+3s-\frac32\right)ds\\ &=\left[-\frac{s^3}{3}+\frac{3s^2}{2}-\frac{3s}{2}\right]_1^2\\ &=\left(-\frac83+6-3\right) -\left(-\frac13+\frac32-\frac32\right)\\ &=\frac13-\left(-\frac13\right) =\frac23. \end{aligned} $$

The result is consistent with symmetry. The two tails, \(S_3<1\) and \(S_3>2\), have equal probabilities, each \(1/6\), leaving probability \(2/3\) between 1 and 2.

Worked Example: An Upper-Tail Probability

Calculate \(P(S_3>2.5)\).

Since \(2.5\) lies in the last piece, integrate that piece up to the endpoint of the support:

$$ \begin{aligned} P(S_3>2.5) &=\int_{2.5}^{3}\frac{(3-s)^2}{2}\,ds\\ &=\left[-\frac{(3-s)^3}{6}\right]_{2.5}^{3}\\ &=0-\left(-\frac{(0.5)^3}{6}\right) =\frac{1}{48}. \end{aligned} $$

The small probability is reasonable: all three variables must collectively be close to their maximum possible sum of 3. The calculation also illustrates why using the last piece, rather than the middle one, is essential.

Worked Example: Rescaling the Three Uniform Variables

Suppose \(X_i=2+3U_i\) for \(i=1,2,3\), where the \(U_i\) are independent Uniform(0,1) variables. Find \(P(9< X_1+X_2+X_3<12)\).

Writing \(T=X_1+X_2+X_3\) gives \(T=6+3S_3\). Therefore, \(9<T<12\) is equivalent to \(1<S_3<2\). The probability is

$$ P(9<T<12)=P(1<S_3<2) =\int_1^2\left(-s^2+3s-\frac32\right)ds =\frac23. $$

The event can also be checked against the support: each \(X_i\) lies in \([2,5]\), so \(T\) lies in \([6,15]\), and the interval \((9,12)\) is possible. The transformation changes the scale and location of the sum, but the event maps exactly to the stated interval for \(S_3\).

Common Mistakes and Why the Shape Matters

These densities are useful both as concrete distributions and as models for understanding how adding independent variables changes a distribution. Even in this simple setting, the support and the density pieces must be tracked carefully.

  • Assuming a sum of uniform variables is uniform. The density of \(S_2\) is proportional to the length of an overlap interval, not constant across its support. For example, \(f_{S_2}(0.2)=0.2\), while \(f_{S_2}(1)=1\).
  • Using one formula across the whole support. The relevant overlap changes at 1 for \(S_2\), and at 1 and 2 for \(S_3\). The middle region for \(S_3\) also requires splitting its integral where \(s-u=1\).
  • Confusing the density with a probability. A density value such as \(f_{S_3}(1.5)=0.75\) is not the probability that \(S_3=1.5\). For a continuous random variable, probabilities are integrals over intervals, and a single point has probability zero.
  • Forgetting the support. The two-variable sum cannot be outside \([0,2]\), and the three-variable sum cannot be outside \([0,3]\). The density is zero elsewhere.

The piecewise forms arise because the set of inputs that can produce a given sum expands, then contracts, as the sum moves through its support. For two variables, the overlap length is linear. Adding a third variable integrates that linear density, producing quadratic pieces. The breakpoints mark where the geometry of the contributing region changes.

Key takeaway: For independent Uniform(0,1) variables, derive the sum density by tracking which input values are compatible with each fixed sum. The overlap gives the triangular density for two variables; integrating that density over the changing overlap gives the piecewise quadratic density for three.

Check Your Understanding

Use the support, the appropriate density piece, and integration to answer each question.

  1. For \(S_2=U_1+U_2\), why does the density increase on \((0,1)\) and decrease on \((1,2)\)?
  2. Use the triangular density to calculate \(P(0.5<S_2<1.5)\).
  3. For \(S_3=U_1+U_2+U_3\), which density piece applies at \(s=2.4\), and what is \(f_{S_3}(2.4)\)?
  4. Explain why the convolution integral for \(S_3\) must be split when \(1<s<2\).
  5. Use symmetry to relate \(P(S_3<0.7)\) to an upper-tail probability.