The continuous uniform distribution
A random variable X follows a uniform distribution on [a, b] when every value in the interval is equally likely. Its density is flat: 1 ÷ (b − a) between a and b, and zero outside. It describes a random arrival time within a known window, a rounding error between −0.5 and 0.5, or a random point on a segment, and it is the starting point of computer simulation, since random-number generators produce uniform values on [0, 1].
The formulas
- P(X ≤ x) = (x − a) ÷ (b − a) for x between a and b (0 below a, 1 above b).
- P(c ≤ X ≤ d) = (length of the overlap of [c, d] with [a, b]) ÷ (b − a).
- Mean (a + b) ÷ 2, the midpoint.
- Variance (b − a)² ÷ 12, so the standard deviation is (b − a) ÷ √12 ≈ 0.289 × (b − a).
- The p-th percentile is a + p × (b − a).
Example
X is uniform on [0, 10]:
- P(X ≤ 3) = 3 ÷ 10 = 0.3;
- P(2 ≤ X ≤ 5) = 3 ÷ 10 = 0.3;
- the density is 0.1, the mean 5, the variance 8.33 and the standard deviation 2.89;
- the 90th percentile is 9.
A practical reading: if a bus comes every 10 minutes and you arrive at a random time, your wait is uniform on [0, 10]. You wait 5 minutes on average, and there is a 30% chance of waiting 3 minutes or less.
Probabilities are lengths
For a uniform distribution, a probability is simply a ratio of lengths. The probability of any single exact value is zero; only intervals have positive probability. That is why P(X ≤ x) and P(X < x) are equal.
Uses
- Simulation: any distribution can be generated from a uniform value U on [0, 1] by applying the inverse of its cumulative distribution function (the inverse transform method).
- Measurement and rounding error: a value rounded to the nearest unit has an error uniform on [−0.5, 0.5], with a standard deviation of 1 ÷ √12 ≈ 0.29 unit. Metrology uses this to turn a tolerance ±h into a standard uncertainty h ÷ √3.
- Bayesian statistics: a uniform prior expresses no preference among values in a range.
Discrete uniform
For a fair die or a random integer from 1 to n, the distribution is discrete: each value has probability 1 ÷ n, the mean is (n + 1) ÷ 2 and the variance (n² − 1) ÷ 12.