TL;DR
The uniform distribution is the model of "every value in this range is equally likely." Its density is flat: the same height everywhere between two endpoints and , and zero outside them. The height is , so the area under the flat line is exactly one.
It is the simplest continuous distribution, and it is the starting point for almost every other one, because computers generate uniform random numbers and every other distribution is built from them.
Where you'll see it: in random number generators, in the random starting weights and noise used in simulations, and in the sampling steps of Monte Carlo methods and rejection sampling.
Intuition
Equal chances across a range
Picture a spinner with a pointer that stops at a random angle. Every angle is equally likely to be where it stops, so no part of the dial is favoured. Now stretch the dial into a straight line segment. Each piece of the segment, if it is the same width, has the same chance of containing the result. That is the uniform distribution.
A real example is a bus that arrives at a random moment in a ten-minute window, when you know nothing about the timetable except that it comes once every ten minutes and you turned up at a random point in that cycle. Your waiting time is uniform between zero and ten minutes.
When should you reach for it? When you know a quantity lies between two limits and you have no good reason to prefer any part of that range over another. Pierre-Simon Laplace argued around the turn of the 19th century that this kind of ignorance should be modelled by equal chances. That argument is the "principle of indifference," and the uniform distribution is its formal version.
The density is a flat line over the interval, and the probability of any sub-interval is simply the fraction of the whole that it covers.
- uniform on [0, 2]
Only the endpoints matter
Within the interval, nothing distinguishes one point from another. The density does not peak in the middle, lean to one side, or taper at the edges. Two numbers, the endpoints, describe the whole model. That makes it a useful baseline: anything more elaborate has to justify the extra structure it adds.
The math
Definition
A continuous random variable is uniform on the interval from to , written , when its density is
where are the two endpoints.
The symbol is the width of the interval. The density is the reciprocal of that width. Check that it is a valid density: it is never negative, and the area is the width times the height,
The integral is a definite integral of a constant, which is just the constant times the width.
Probabilities are fractions of the width
For any sub-interval inside ,
The probability is the length of the sub-interval divided by the length of the whole interval. Nothing else enters. This is the whole meaning of "equally likely" for a continuous variable.
The cumulative distribution function
The CDF is the running total of probability. Integrate the density from the far left up to :
Below there is no probability yet, so is zero. Above all probability has been counted, so is one. In between, rises in a straight line from 0 to 1. Its slope is , which is the density, as the fundamental theorem of calculus requires.
Mean and variance
The mean is the expected value of :
Factor the top as and the cancels:
The mean is the midpoint, as symmetry suggests.
For the variance, first compute the second moment:
Then subtract the square of the mean:
The standard deviation is therefore
The spread is always about 29 percent of the width. A uniform distribution on a wide interval is wide, but it is never as spread out as its endpoints might suggest.
Generating uniform samples
A computer's random number generator gives samples that approximate . Any other uniform variable can be built from one:
Check this with the CDF. The event is the same as , so
That is the CDF of , so the transformed variable has the right distribution. The same idea, applying the inverse of a CDF to a uniform draw, is the inverse transform method, which uses the CDF to generate samples from almost any distribution.
Worked examples
Let . The width is , so the density is on and zero elsewhere.
- Probability of landing between 0.5 and 1.5: .
- The same answer from the CDF: and , so .
- The mean is .
- The variance is , so the standard deviation is about .
Interpretation: the middle half of the interval, from 0.5 to 1.5, holds exactly half of the probability. That is what "uniform" means. Each unit of width carries the same share, so the middle half of the width carries half the mass.
A bus comes every 10 minutes, and you arrive at the stop at a random time. Your wait is uniform on minutes, so there.
- Chance the wait is longer than 7 minutes: .
- Chance the wait is at most 4 minutes: .
- Chance the wait is longer than 7 minutes, given you have already waited more than 4: .
- Expected wait: minutes.
- Standard deviation of the wait: minutes.
Interpretation: step 3 shows that the uniform is not memoryless. Having already waited 4 minutes, you know lies in , and given that it is still uniform, now over a window of 6 minutes. The chance of waiting more than 3 further minutes is , whereas at the start it was . Waiting makes the bus more likely to arrive soon, because the window is shrinking. The distribution that forgets how long you have waited is the exponential, not the uniform. The uniform fits only when your arrival time is random relative to a fixed ten-minute cycle.
Tradeoffs and failure modes
The uniform model is only as good as its endpoints. Choosing and is the entire modelling decision, and a wrong choice cannot be fixed by anything else in the model.
| Situation | What goes wrong with a uniform | Better choice |
|---|---|---|
| Error is the sum of many small independent causes | The uniform has hard edges and too little mass in the middle; real errors are bell-shaped | [[gaussian-distribution |
| The true value might sometimes fall outside your range | The model assigns zero probability to values that do happen | A wider range, or a distribution with unbounded support |
| You need samples from a distribution with a known CDF | The uniform does not produce that shape by itself | Inverse transform, or [[rejection-sampling |
| The outcome is one of a finite set (a die face, a card) | A continuous uniform is the wrong type of variable | The discrete uniform on the finite set |
| You want a "non-informative" prior on a parameter | A uniform on is not uniform on , so the prior depends on how you parametrise | Think about scale first, and choose a prior that is uniform on the natural scale |
The last row is a real trap. "Equal chances" depends on the variable you choose to be uniform. A uniform on the number puts a different belief on than a uniform on does. Pick the scale that matches what you actually know.
History
The idea of splitting belief equally over possibilities you cannot tell apart is much older than the formal distribution. Pierre-Simon Laplace used it as the principle of insufficient reason, later called the principle of indifference. The continuous uniform became a standard model as probability theory came to be expressed through densities and integrals.
Its largest practical role came with computers. In the mid-20th century, researchers needed streams of random numbers for simulations, and the standard approach was to build generators whose outputs look uniform on . Every other random variable in a simulation is then produced by transforming those uniform numbers. The uniform is therefore the foundation of sampling, not just one distribution among many.
Check yourself
QuestionRecall: what is the density of a uniform distribution on [a, b], and why must it have that height?Show answer
The density is on and zero elsewhere. The height must be because the total area under the density must be 1. The base of the rectangle is the width , so the height has to be the reciprocal of that width.
QuestionComputation: if X is uniform on [2, 6], what is P(X ≤ 3.5)?Show answer
The width is . The probability of being at most 3.5 is the length of divided by the width: . Equivalently, .
QuestionWhy: a bus wait is uniform on [0, 10] minutes and you have already waited 4. What is the distribution of the remaining wait, and is it the same as at the start?Show answer
Conditioning on restricts the variable to , and the density there is still flat. The remaining wait is therefore uniform on minutes, with mean 3, not the original uniform on with mean 5. So it is not the same: the uniform is not memoryless, and the bus gets more likely to arrive soon as the window shrinks.
QuestionApplied: a sensor's rounding error is uniform between minus 0.5 and plus 0.5 degrees. A colleague wants to model it as Gaussian noise with standard deviation 0.5. Is that a good match?Show answer
The uniform error has standard deviation , which is smaller than 0.5. A Gaussian with standard deviation 0.5 would put real probability outside , which the sensor can never produce, and it would have a bell shape instead of a flat one. It overstates the spread and the tails. Use the uniform with its exact bounds if you know the error is bounded, and check the mean and variance against the uniform formulas before swapping models.