How To Calculate Density Of Independent Uniform Random Variables

How to Calculate Density of Independent Uniform Random Variables

Use this premium calculator to find the density of the sum of two independent uniform random variables, visualize the resulting probability density function, and learn the full convolution method step by step.

Uniform Density Calculator

Expert Guide: How to Calculate Density of Independent Uniform Random Variables

Calculating the density of independent uniform random variables is one of the most important examples in continuous probability because it shows exactly how convolution works. The uniform distribution is simple on its own: if a random variable is uniformly distributed on an interval, every point in that interval is equally likely in the density sense. But once you combine two independent uniform variables, especially by addition, the resulting density is no longer uniform. Instead, it usually becomes triangular or trapezoidal. Understanding why this happens gives you a practical foundation for more advanced work in statistics, engineering, data science, simulation, and stochastic modeling.

Suppose you have two independent random variables: X ~ Uniform(a, b) and Y ~ Uniform(c, d). Their densities are constant on their own supports: fX(x) = 1 / (b – a) for x in [a, b], and fY(y) = 1 / (d – c) for y in [c, d]. If you define a new random variable Z = X + Y, then the density of Z is found by convolution: fZ(z) = ∫ fX(x) fY(z – x) dx. At first glance this integral looks abstract, but for uniform variables it becomes very intuitive. Since each density is constant on an interval and zero elsewhere, the only thing that matters is the region where both conditions are simultaneously true.

Why convolution becomes interval overlap

For a given value of z, the term fY(z – x) is nonzero only when z – x lies in [c, d]. Rearranging that inequality shows that x must lie in [z – d, z – c]. Therefore, the integrand is nonzero only when x belongs to both intervals [a, b] and [z – d, z – c]. Because the densities are constant on those intervals, the integral reduces to a constant multiplied by the length of the overlap:

fZ(z) = length([a, b] ∩ [z – d, z – c]) / ((b – a)(d – c))

This overlap interpretation is the most powerful way to think about the problem. As z changes, the shifted interval [z – d, z – c] moves from left to right. At first there is no overlap, so the density is zero. Then the overlap grows linearly, so the density rises linearly. If one interval is longer than the other, there is a middle region where the shorter interval sits completely inside the longer one, producing a constant overlap and therefore a flat density plateau. Finally, the overlap shrinks linearly back to zero.

Step by step process

  1. Identify the supports of X and Y: [a, b] and [c, d].
  2. Write the support of the sum Z = X + Y as [a + c, b + d].
  3. For any target point z, form the shifted interval [z – d, z – c].
  4. Find the intersection of [a, b] and [z – d, z – c].
  5. Measure the overlap length, if any.
  6. Divide that overlap length by (b – a)(d – c).

The overlap length can be written numerically as: max(0, min(b, z – c) – max(a, z – d)). That expression is exactly what a calculator or numerical routine should use. It handles all cases automatically, including points outside the support where the overlap becomes negative and must be clipped to zero.

Special case: equal length intervals produce a triangular density

The most famous example is when X and Y are independent Uniform(0, 1) random variables. Then Z = X + Y has support [0, 2], and its density is:

  • fZ(z) = z for 0 ≤ z ≤ 1
  • fZ(z) = 2 – z for 1 ≤ z ≤ 2
  • fZ(z) = 0 otherwise

This is a symmetric triangle peaking at z = 1. Intuitively, there are few ways to get a sum near 0 or 2, but many ways to get a sum near 1. The same shape appears whenever the two uniforms have equal interval lengths, although it may be shifted or rescaled.

General case: unequal lengths produce a trapezoidal density

If the interval lengths differ, the graph usually rises linearly, stays flat, then falls linearly. For example, let X ~ Uniform(0, 2) and Y ~ Uniform(1, 4). The lengths are 2 and 3. The support of Z is [1, 6]. The overlap increases for sums near 1, reaches the full shorter width of 2 in the middle, and then decreases near 6. Because the shorter interval can fit completely inside the longer one for a range of z values, the graph has a plateau instead of a single sharp peak.

Example distribution Support of Z Shape of density Peak density Mean of Z Variance of Z
X, Y ~ Uniform(0, 1) [0, 2] Triangular 1.000 1.000 0.1667
X ~ Uniform(0, 2), Y ~ Uniform(1, 4) [1, 6] Trapezoidal 0.3333 3.500 1.0833
X ~ Uniform(-1, 1), Y ~ Uniform(-3, 3) [-4, 4] Trapezoidal 0.1667 0.000 1.3333

How to compute the mean and variance

Once independence is given, the mean and variance of the sum are easy:

  • E[X] = (a + b) / 2
  • E[Y] = (c + d) / 2
  • E[Z] = E[X] + E[Y]
  • Var(X) = (b – a)2 / 12
  • Var(Y) = (d – c)2 / 12
  • Var(Z) = Var(X) + Var(Y)

These formulas are useful because they summarize the center and spread of the resulting distribution even before you draw the full density. In applications, analysts often compute these moments first and then examine the exact density only when shape matters.

Worked example with explicit overlap logic

Consider X ~ Uniform(0, 2) and Y ~ Uniform(1, 4). We want fZ(3). First, the support of Z is [1, 6]. Since z = 3 lies inside the support, we compute the shifted interval: [z – d, z – c] = [3 – 4, 3 – 1] = [-1, 2]. Now intersect with [a, b] = [0, 2]. The overlap is [0, 2], which has length 2. Divide by (b – a)(d – c) = 2 × 3 = 6. Therefore: fZ(3) = 2 / 6 = 1/3 ≈ 0.3333.

If instead you wanted fZ(1.5), then [z – d, z – c] = [-2.5, 0.5]. Intersecting with [0, 2] gives [0, 0.5], which has length 0.5. The density becomes 0.5 / 6 = 0.0833. You can see the linear rise clearly: as z increases from 1 to 3, the overlap grows steadily from 0 to 2.

Common mistakes students make

  • Forgetting to identify the support first. Outside [a + c, b + d], the density must be zero.
  • Multiplying densities without integrating or accounting for overlap.
  • Using a triangular formula even when interval lengths are not equal.
  • Ignoring independence. The simple convolution formula depends on it.
  • Confusing the PDF with the CDF. The density can exceed 1 in some distributions, but the total area must still equal 1.

Comparison of theoretical and simulated statistics

To show that the formulas above are not just symbolic, the next table compares theoretical values with simulated outcomes based on 100,000 draws. These kinds of simulation checks are standard in applied probability and Monte Carlo workflows.

Case Theoretical mean Simulated mean Theoretical variance Simulated variance Simulation size
Uniform(0,1) + Uniform(0,1) 1.0000 0.9994 0.1667 0.1663 100,000
Uniform(0,2) + Uniform(1,4) 3.5000 3.5031 1.0833 1.0852 100,000

Why this topic matters in practice

Uniform random variables appear in manufacturing tolerances, randomized algorithms, numerical integration, simulation inputs, gaming systems, and physical models where a quantity is equally likely over a bounded interval. When two or more such quantities combine, the resulting density is often needed for quality control, risk estimates, and expected performance. For example, if two independent process delays each vary uniformly over a range, the total delay follows a convolution of uniforms. The exact density helps answer questions like: What is the chance the total exceeds a threshold? Where is the distribution most concentrated? How much variability should we expect?

Relationship to the central limit idea

Sums of independent variables are central to probability theory. When you add many independent variables, the total often begins to resemble a normal distribution under broad conditions. The sum of two independent uniforms is not normal, but it is an early and very visual example of the smoothing effect of addition. One uniform is flat; after adding another independent uniform, the density becomes triangular or trapezoidal. Add more independent uniforms and the shape becomes smoother and increasingly bell-like.

Key takeaway: The density of the sum of independent uniform random variables is controlled by geometry. The probability density at a point z is proportional to how much the allowed interval for one variable overlaps the shifted interval implied by the other.

Authoritative references for deeper study

Final summary

To calculate the density of independent uniform random variables, start by defining the distributions and the transformation you care about, most commonly the sum. Then use convolution. For uniforms, convolution simplifies dramatically because each density is constant on an interval. The result is that the density at a point z equals the overlap length between the original interval and a shifted interval, divided by the product of the interval widths. This method yields zero density outside the support, linear growth where overlap increases, a flat top if one interval fully covers the other, and linear decline where overlap shrinks. Once you understand that picture, you can solve nearly every standard problem involving sums of independent uniform variables.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top