Uniform Distribution
The distribution that spreads probability evenly, either over an interval or over a finite set of equally likely values.
Prerequisites: Probability Distributions, Expected Value, Variance of a Random Variable.
The uniform distribution spreads probability evenly. In its continuous form, every stretch of the same length inside an interval from to is equally likely to contain the value, and values outside the interval are impossible. In its discrete form, each of a finite set of values, such as the six faces of a fair die, has the same probability.
It is the simplest model of “no value is favoured over any other” and is mostly useful for that reason: as a model of complete uncertainty within known limits, as a building block in probability arguments, and as the starting point of almost every computer simulation, since random number generators produce (approximately) uniform numbers between and .
Intuition
Suppose a bus comes every 20 minutes and you arrive at the stop at a random moment, without checking the timetable. Your waiting time could be anything from to minutes, and there is no reason for any part of that range to be more likely than another. The chance of waiting between 0 and 5 minutes is the same as the chance of waiting between 15 and 20 minutes: each stretch is a quarter of the window, so each has probability .
That is the continuous uniform distribution: probability is proportional to length. Its density is flat, like a rectangle, and the height of the rectangle is whatever makes its area equal to .
Definition
A continuous random variable has a uniform distribution on the interval from to , written , if its probability density function is
The two parameters are the endpoints and , any real numbers with . The height is fixed by the requirement that the total area is : a rectangle of width and height has area exactly . The special case is called the standard uniform distribution.
Whether the endpoints are included makes no difference, because a single point has probability for a continuous variable.
Probabilities are lengths
For any interval inside ,
the length of the interval divided by the length of the whole range. The cumulative distribution function is
a straight ramp from to across the interval, as in the right panel of the figure.
Mean and variance
If , then
The mean is the midpoint of the interval, as symmetry suggests. It also follows from the integral:
using . For the variance, first compute
using . Then
(Put both fractions over : the numerator is .)
So the variance depends only on the width of the interval, not on where it sits, and the standard deviation is . For the standard uniform, .
How the shape depends on a and b
There is only one shape, a rectangle; the parameters move and stretch it.
- Shifting and by the same amount moves the rectangle without changing it, just as changing the mean of a normal distribution moves its bell curve.
- Widening the interval makes the rectangle lower, since the area must stay . A narrow interval gives a tall rectangle, and the density can exceed : has density on its interval.
Worked example
A bus arrives every 20 minutes and you turn up at a random time, so your waiting time in minutes is , with density on that interval.
Step 1: average wait. minutes.
Step 2: a long wait. The probability of waiting more than 15 minutes is the length from 15 to 20 divided by 20:
Step 3: a range. The probability of waiting between 5 and 8 minutes is .
Step 4: spread. square minutes, so the standard deviation is minutes. A typical wait is about 6 minutes away from the 10-minute average, which fits a range that runs evenly from 0 to 20.
The discrete uniform distribution
A discrete uniform distribution puts equal probability on each of a finite set of values. The roll of a fair six-sided die is the standard example: for .
It differs from the continuous version in the usual way that discrete and continuous distributions differ: each possible value has a positive probability, , rather than a density, and probabilities of sets are sums rather than areas. The mean is again the midpoint, , but the variance is not . For the die,
whereas the continuous formula with and would give .
Uniform numbers in simulation
Computers generate pseudo-random numbers that behave like independent draws from . Almost every other random quantity in a simulation is built from these.
- Other uniform ranges. If , then : stretch the unit interval to width , then shift it to start at .
- Yes/no events. “” is true with probability , which simulates a Bernoulli trial.
- Other continuous distributions. If is a continuous CDF with inverse , then has CDF . This is called inverse transform sampling. For example, has an exponential distribution with rate .
Common misunderstandings
“Uniform means every exact value has the same probability.” For the continuous uniform, every exact value has probability . What is equal is the probability of intervals of equal length.
“Random means uniform.” Random only means uncertain. Most random quantities are not uniform: heights cluster around a typical value, waiting times between random events are more often short than long. Choosing a uniform distribution is a modelling assumption that needs a reason, such as the bus timetable above.
“A uniform prior means knowing nothing.” A uniform distribution on a quantity is not uniform on transformations of it. If a length is uniform between 1 and 2, its square is not uniform between 1 and 4. “Flat” depends on the scale you choose.
“The density must be at most 1.” A density is not a probability. A uniform distribution on a short interval has a density greater than .
Further reading
- Joseph K. Blitzstein and Jessica Hwang, Introduction to Probability, 2nd ed., CRC Press, 2019. Discusses the uniform distribution and its role in generating other distributions (the universality of the uniform).
- Larry Wasserman, All of Statistics: A Concise Course in Statistical Inference, Springer, 2004. Brief reference treatment alongside the other standard distributions.