Uniform Distribution
The uniform distribution on an interval [a, b] gives every interval of the same length inside [a, b] the same probability. Its density is f(x) = 1/(b − a) on [a, b], so P(c ≤ X ≤ d) = (d − c)/(b − a). Its mean is (a + b)/2, and its variance is (b − a)²/12.
Before this lesson: Probability Density Functions, Cumulative Distribution Functions and Expected Value of a Continuous Random Variable
Equally likely, but continuous
A bus comes every 15 minutes, and you arrive at a random moment. Your wait X is somewhere between 0 and 15 minutes, and no part of that range is favored. A wait between 2 and 3 minutes is just as likely as a wait between 11 and 12 minutes.
That makes the density flat. The total area must be 1, so a rectangle of width 15 has height 1/15. Every probability is then a rectangle area: length of the interval divided by 15.
Uniform distribution formulas
X has a uniform distribution on [a, b], written X ~ U(a, b), when
f(x) = \dfrac{1}{b-a} \text{ for } a \le x \le b, \qquad F(x) = \dfrac{x-a}{b-a} \text{ for } a \le x \le bwith f(x) = 0 outside [a, b], F(x) = 0 for x below a and F(x) = 1 for x above b. For a ≤ c ≤ d ≤ b,
P(c \le X \le d) = \dfrac{d-c}{b-a}, \qquad E(X) = \dfrac{a+b}{2}, \qquad \operatorname{Var}(X) = \dfrac{(b-a)^2}{12}Steps
- Identify a and b, the ends of the interval.
- For a probability, divide the length of the part of the interval you want by b − a.
- For the mean, take the midpoint (a + b)/2.
- For the standard deviation, divide b − a by √12.
Uniform distribution examples
Example 1: Waiting for a bus (word problem)
A bus comes every 15 minutes, and your wait X is uniform on [0, 15]. Find P(X ≤ 4), P(5 ≤ X ≤ 12), the mean wait and the standard deviation.
f(x) = \dfrac{1}{15 - 0} = \dfrac{1}{15}Height of the density.
P(X \le 4) = \dfrac{4 - 0}{15} = \dfrac{4}{15} \approx 0.267Length 4 divided by 15.
P(5 \le X \le 12) = \dfrac{12 - 5}{15} = \dfrac{7}{15} \approx 0.467Length 7 divided by 15.
E(X) = \dfrac{0 + 15}{2} = 7.5Midpoint of the interval.
\sigma = \dfrac{15}{\sqrt{12}} \approx 4.33Square root of (b − a)²/12.
Answer: 4/15 ≈ 0.267 and 7/15 ≈ 0.467; the mean wait is 7.5 minutes with a standard deviation of about 4.33 minutes.
Example 2: Deriving the mean and variance
Show that X ~ U(a, b) has mean (a + b)/2 and variance (b − a)²/12.
E(X) = \int_a^b \dfrac{x}{b-a}\,dx = \dfrac{b^2 - a^2}{2(b-a)}Multiply x by the density and integrate.
E(X) = \dfrac{(b-a)(b+a)}{2(b-a)} = \dfrac{a+b}{2}Factor the difference of squares and cancel b − a.
E(X^2) = \int_a^b \dfrac{x^2}{b-a}\,dx = \dfrac{b^3 - a^3}{3(b-a)}Multiply x² by the density and integrate.
E(X^2) = \dfrac{(b-a)(b^2 + ab + a^2)}{3(b-a)} = \dfrac{a^2 + ab + b^2}{3}Factor the difference of cubes and cancel.
\operatorname{Var}(X) = \dfrac{a^2 + ab + b^2}{3} - \dfrac{(a+b)^2}{4}Subtract the square of the mean.
\operatorname{Var}(X) = \dfrac{4a^2 + 4ab + 4b^2 - 3a^2 - 6ab - 3b^2}{12}Use the common denominator 12 and expand.
\operatorname{Var}(X) = \dfrac{a^2 - 2ab + b^2}{12} = \dfrac{(b-a)^2}{12}Combine like terms and factor the perfect square.
Answer: E(X) = (a + b)/2 and Var(X) = (b − a)²/12, as claimed.
Example 3: Delivery time and a conditional probability
A pizza arrives X minutes after you order, with X uniform on [20, 50]. Find the CDF, P(X \gt 40), the 90th percentile, and the probability that it arrives by minute 40 given that it hasn’t arrived by minute 30.
F(x) = \dfrac{x - 20}{30} \text{ for } 20 \le x \le 50CDF of U(20, 50).
P(X \gt 40) = 1 - F(40) = 1 - \dfrac{20}{30} = \dfrac{1}{3}Complement rule.
\dfrac{x - 20}{30} = 0.9The 90th percentile has F(x) = 0.9.
x = 20 + 27 = 47
Multiply both sides by 30 and add 20.
P(X \le 40 \mid X \gt 30) = \dfrac{P(30 \lt X \le 40)}{P(X \gt 30)}Definition of conditional probability.
P(X \le 40 \mid X \gt 30) = \dfrac{10/30}{20/30} = \dfrac{1}{2}Rectangle areas; the 30s cancel.
Answer: P(X \gt 40) = 1/3, the 90th percentile is 47 minutes, and the conditional probability is 1/2. Given no pizza by minute 30, the arrival time is uniform on the 20 minutes that remain.
Example 4: Finding a and b
X is uniform with mean 10 and standard deviation 2. Find a and b.
\dfrac{a+b}{2} = 10 \implies a + b = 20Set the mean equal to 10.
\dfrac{b-a}{\sqrt{12}} = 2 \implies b - a = 2\sqrt{12} = 4\sqrt{3}Set the standard deviation equal to 2 (see simplifying square roots).
2b = 20 + 4\sqrt{3}Add the two equations (see elimination method).
b = 10 + 2\sqrt{3} \approx 13.46Divide both sides by 2.
a = 20 - b = 10 - 2\sqrt{3} \approx 6.54Substitute into a + b = 20.
Answer: X ~ U(10 − 2√3, 10 + 2√3), about U(6.54, 13.46).
Example 5: Rounding error
A scale rounds every weight to the nearest 0.1 kg, so the rounding error R is uniform on [−0.05, 0.05]. Find the mean and standard deviation of R, and the probability that the error is at most 0.02 kg in size.
E(R) = \dfrac{-0.05 + 0.05}{2} = 0Midpoint of the interval.
\operatorname{Var}(R) = \dfrac{(0.1)^2}{12} = \dfrac{0.01}{12} \approx 0.000833Here b − a = 0.1.
\sigma = \dfrac{0.1}{\sqrt{12}} \approx 0.0289Take the square root.
P(-0.02 \le R \le 0.02) = \dfrac{0.04}{0.1} = 0.4Length 0.04 divided by 0.1.
Answer: the mean error is 0, the standard deviation is about 0.0289 kg, and the error is at most 0.02 kg in size with probability 0.4.
Common mistakes
| Mistake | Example of the error | Fix |
|---|---|---|
| Using height 1 instead of 1/(b − a) | Saying P(5 ≤ X ≤ 12) = 7 in Example 1 | Divide the length by b − a: 7/15. |
| Dividing by b instead of b − a | P(X ≤ 30) = 30/50 for X ~ U(20, 50) | Measure from a: (30 − 20)/(50 − 20) = 1/3. |
| Halving the length for the mean | Mean of U(20, 50) = (50 − 20)/2 = 15 | The mean is the midpoint: (20 + 50)/2 = 35. |
| Forgetting to square in the variance | Var = 15/12 = 1.25 in Example 1 | Var = 15²/12 = 18.75, so σ ≈ 4.33. |
| Giving a single value a positive probability | P(X = 5) = 1/15 in Example 1 | For a continuous variable, P(X = 5) = 0; 1/15 is the density. |
Related ideas
Discrete uniform distribution
A fair die is a discrete uniform variable: each of the values 1 to 6 has probability 1/6. Its mean, 3.5, is still the midpoint, but its variance is (n² − 1)/12 = 35/12, not the continuous formula (see discrete random variables).
The standard uniform and random numbers
U(0, 1) is the standard uniform distribution. Calculators and computers produce random numbers from it, and plugging one into the inverse of a CDF produces a random value from that distribution.
Uniform probabilities in statistics
The density curves lesson in Statistics treats the uniform density with geometry alone. The calculus here adds the mean, the variance and the CDF formulas.
Practice problems
- X ~ U(0, 20). Find P(X ≤ 5).
- X ~ U(0, 20). Find P(8 ≤ X ≤ 14).
- X ~ U(3, 11). Find the mean and variance.
- X ~ U(−2, 4). Find the density and P(X ≤ 0).
- X ~ U(10, 30). Find the 75th percentile.
- X ~ U(0, 60). Given X \gt 20, find the probability that X ≤ 40.
- Find the standard deviation of the standard uniform distribution, U(0, 1).
- X ~ U(4, b) has mean 9. Find b.
- X ~ U(0, 3). Find E(X²).
- A point is chosen at random on a 12-inch ruler. Find the probability that it is within 1 inch of either end.
Show answers
1.
P(X \le 5) = \dfrac{5 - 0}{20} = \dfrac{1}{4}Length divided by b − a = 20.
Answer: 1/4
2.
P(8 \le X \le 14) = \dfrac{14 - 8}{20} = \dfrac{6}{20} = \dfrac{3}{10}Length 6 divided by 20, then simplify.
Answer: 3/10
3.
E(X) = \dfrac{3 + 11}{2} = 7Midpoint.
\operatorname{Var}(X) = \dfrac{(11 - 3)^2}{12} = \dfrac{64}{12} = \dfrac{16}{3}Use the variance formula and simplify.
Answer: mean 7, variance 16/3 ≈ 5.33
4.
f(x) = \dfrac{1}{4 - (-2)} = \dfrac{1}{6}Height of the density on [−2, 4].
P(X \le 0) = \dfrac{0 - (-2)}{6} = \dfrac{2}{6} = \dfrac{1}{3}Length 2 divided by 6.
Answer: f(x) = 1/6 on [−2, 4], and P(X ≤ 0) = 1/3
5.
\dfrac{x - 10}{20} = 0.75Set the CDF equal to 0.75.
x = 10 + 15 = 25
Multiply both sides by 20 and add 10.
Answer: 25
6.
P(X \le 40 \mid X \gt 20) = \dfrac{(40 - 20)/60}{(60 - 20)/60}Conditional probability with rectangle areas.
P(X \le 40 \mid X \gt 20) = \dfrac{20}{40} = \dfrac{1}{2}Cancel the 60s and simplify.
Answer: 1/2
7.
\sigma = \dfrac{1 - 0}{\sqrt{12}} = \dfrac{1}{\sqrt{12}} \approx 0.2887Divide b − a by √12.
Answer: about 0.2887
8.
\dfrac{4 + b}{2} = 9Set the mean equal to 9.
4 + b = 18
Multiply both sides by 2.
b = 14
Subtract 4 from both sides.
Answer: b = 14
9.
E(X^2) = \int_0^3 \dfrac{x^2}{3}\,dx = \left[\dfrac{x^3}{9}\right]_0^3 = 3Multiply x² by the density 1/3 and integrate.
Answer: 3 (check: Var + mean² = 9/12 + 2.25 = 3)
10.
P(X \le 1) + P(X \ge 11) = \dfrac{1}{12} + \dfrac{1}{12}X ~ U(0, 12); the two end pieces don’t overlap.
P = \dfrac{2}{12} = \dfrac{1}{6}Add and simplify.
Answer: 1/6
Uniform distribution FAQ
What is a uniform distribution?
It is a distribution in which every value in an interval [a, b] is equally likely, so the density is flat at height 1/(b − a). The probability of any piece of the interval is proportional to its length.
What are the mean and variance of a uniform distribution?
For X ~ U(a, b), the mean is (a + b)/2 and the variance is (b − a)²/12. The standard deviation is (b − a)/√12.
What is the difference between discrete and continuous uniform distributions?
A discrete uniform variable takes a finite list of values, each with the same probability, like a die roll. A continuous uniform variable can take any value in an interval, and only intervals have positive probability.
Why is the variance of a uniform distribution divided by 12?
The 12 comes from the integral: E(X²) has a 3 in the denominator and the squared mean has a 4, and their common denominator is 12. Example 2 shows the full derivation.
Summary
- X ~ U(a, b) has the flat density f(x) = 1/(b − a) on [a, b].
- Probabilities are lengths divided by b − a.
- F(x) = (x − a)/(b − a) on [a, b].
- The mean is (a + b)/2, and the variance is (b − a)²/12.
- Given that X is past some point, X is still uniform on what remains.
Previous lesson: Expected Value of a Continuous Random Variable
Next lesson: Exponential Distribution
Back to the Probability Theory Index