Uni-Sine
MathematicsStatistics

The uniform distribution

A uniform distribution is one where every outcome in a range is equally likely. The discrete uniform distribution covers a fixed set of values, like the score on a fair dice. The continuous uniform distribution, X ~ U(a, b), covers every value between a and b, with probability density f(x) = 1/(b − a). Its graph is a flat rectangle, so it is also called the rectangular distribution. Its mean is (a + b)/2 and its variance is (b − a)²/12.

Discrete uniform distribution

If a random variable X can take n different values, each equally likely, then each has probability 1/n. Pearson Edexcel's A-level Maths specification expects students to know and be able to identify the discrete uniform distribution. A fair six-sided dice is the classic example: P(X = x) = 1/6 for x = 1, 2, 3, 4, 5, 6.

For the values 1, 2, ..., n, the mean and variance are:

E(X) = \frac{n + 1}{2} \qquad \text{Var}(X) = \frac{n^2 - 1}{12}

Where the formulas come from

The mean is the sum of the values times 1/n. The sum 1 + 2 + ... + n is n(n + 1)/2, so E(X) = (n + 1)/2. For the variance, use E(X²) − [E(X)]². The sum of the squares 1² + ... + n² is n(n + 1)(2n + 1)/6, so:

\text{Var}(X) = \frac{(n+1)(2n+1)}{6} - \frac{(n+1)^2}{4} = \frac{(n+1)(n-1)}{12} = \frac{n^2-1}{12}

Example 1: a fair eight-sided spinner

A fair spinner is numbered 1 to 8. X is the score.

  • Each score has P(X = x) = 1/8.
  • P(X > 5) = P(6, 7 or 8) = 3/8 = 0.375.
  • E(X) = (8 + 1)/2 = 4.5. It's the middle of the range, even though 4.5 isn't a possible score.
  • Var(X) = (8² − 1)/12 = 63/12 = 5.25.

Continuous uniform distribution

OpenStax describes the continuous uniform distribution as a continuous distribution for outcomes that are equally likely, written X ~ U(a, b), where a is the lowest value and b the highest. The probability density function is constant across the range and zero outside it:

f(x) = \frac{1}{b - a} \quad \text{for } a \le x \le b

The graph shows the pdf of X ~ U(2, 10): f(x) (up) against x (across). The height is 1/8 = 0.125, so the rectangle has width 8 and height 1/8, and its area is 1, as every pdf's area must be.

Probability density of X ~ U(2, 10)
123456789101112-0.020.020.040.060.080.10.120.14x = 3x = 6.5
A flat line at height 0.125 from x = 2 to x = 10, and zero elsewhereDrag to pan, scroll to zoom. x from 0 to 12, y from -0.025 to 0.15.

Finding probabilities

A probability is the area under the pdf, and here every area is a rectangle: width × height. OpenStax puts it the same way: base times height, with height 1/(b − a). So:

P(c < X < d) = \frac{d - c}{b - a} \quad \text{for } a \le c < d \le b

For X ~ U(2, 10): P(3 < X < 6.5) = (6.5 − 3)/(10 − 2) = 3.5/8 = 0.4375. For a continuous distribution, the probability of any single exact value is 0, so it doesn't matter whether you write < or ≤. OpenStax warns to check whether a question includes the endpoints for discrete data, where it does matter.

Mean, variance and the cumulative distribution function

E(X) = \frac{a + b}{2} \qquad \text{Var}(X) = \frac{(b - a)^2}{12} \qquad F(x) = \frac{x - a}{b - a}

Edexcel's Further Maths specification includes deriving all three. The mean comes from integrating x f(x):

E(X) = \int_a^b \frac{x}{b-a}\ dx = \frac{b^2 - a^2}{2(b-a)} = \frac{a+b}{2}

For the variance, E(X²) = (b³ − a³)/(3(b − a)) = (a² + ab + b²)/3. Subtracting the square of the mean:

\text{Var}(X) = \frac{a^2 + ab + b^2}{3} - \frac{(a+b)^2}{4} = \frac{(b-a)^2}{12}

For X ~ U(2, 10): E(X) = 6, Var(X) = 8²/12 = 5.33 and the standard deviation is √5.33 = 2.31. The cumulative distribution function F(x) = P(X ≤ x) rises in a straight line from 0 at x = a to 1 at x = b.

practice
Pick an answer, then check it.
X ~ U(0, 20). What is P(X > 15)?

Worked examples

Example 2: waiting for a train

Trains on a line leave every 20 minutes, and a passenger arrives at a random time. Model the waiting time W minutes as W ~ U(0, 20).

  1. P(W > 12) = (20 − 12)/20 = 0.4.
  2. E(W) = (0 + 20)/2 = 10 minutes, and Var(W) = 20²/12 = 33.3, so the standard deviation is 5.77 minutes.
  3. Given the passenger has already waited 5 minutes, what is the chance of waiting more than 12 in total? The remaining range is 5 to 20, so P(W > 12 | W > 5) = (20 − 12)/(20 − 5) = 8/15 = 0.533.

The last part uses the trick OpenStax describes for conditional probability: shrink the range to what you know, and the distribution is still uniform on the new range.

Example 3: rounding errors

A length is measured and rounded to the nearest centimetre. The rounding error, E cm, could be anything from −0.5 to 0.5, so model it as E ~ U(−0.5, 0.5).

  1. E(E) = (−0.5 + 0.5)/2 = 0: on average, rounding doesn't bias the answer.
  2. Var(E) = (0.5 − (−0.5))²/12 = 1/12 = 0.0833, so the standard deviation is 0.289 cm.
  3. P(the error is more than 0.3 cm either way) = P(E < −0.3) + P(E > 0.3) = 0.2 + 0.2 = 0.4.

When to use a uniform model

  • Discrete uniform: a fair dice, a fair spinner, choosing one item at random from a numbered list.
  • Continuous uniform: arriving at a random moment for something that happens at regular intervals, rounding errors, the position of a random cut along a length.
  • Not uniform: heights, exam marks or reaction times, which bunch up around a middle value. A normal distribution usually fits those better. Counting successes in repeated trials needs the binomial distribution.

Common mistakes

  • Using n/12 for the discrete variance. It is (n² − 1)/12 for the values 1 to n.
  • Thinking f(x) is a probability. In the continuous case, probabilities are areas; f(x) is the height, and can be bigger than 1 if the range is narrow.
  • Forgetting zero outside the range. For X ~ U(2, 10), P(X < 1) = 0.
  • Applying the continuous formula to dice. A dice isn't U(1, 6): it can't score 2.7. Use the discrete formulas.
  • Conditional probability with the wrong denominator. Divide by the width of the range you know the value is in.

Practise probability distributions on today's A-level Maths: Statistics or A-level Further Maths short timed paper, and check probabilities with the probability calculator.

Common questions

What is a uniform distribution?
A probability distribution where every outcome in a range is equally likely. It can be discrete (a fixed set of values) or continuous (every value between a and b).
What is the formula for the continuous uniform distribution?
f(x) = 1/(b − a) for a ≤ x ≤ b, and 0 otherwise.
What is the mean of a uniform distribution?
(a + b)/2 for the continuous case, and (n + 1)/2 for the discrete values 1 to n.
What is the variance of a uniform distribution?
(b − a)²/12 for the continuous case, and (n² − 1)/12 for the discrete values 1 to n.
Why is it called a rectangular distribution?
Because the graph of its probability density function is a flat line, so the area under it is a rectangle.
How do you find a probability for a continuous uniform distribution?
Divide the width of the interval you want by the width of the whole range: P(c < X < d) = (d − c)/(b − a).

Revision cards

Say the answer first, then flip the card to check it.

Where to go next

  • Solve it

    Probability Calculator

    Visualise probability distributions and events

    Open the tool
  • Learn it

    Probability

    Distributions, expected values and the maths behind uncertainty

    Start the course
  • Test it

    A-level Maths: Statistics

    A new exam-style paper every day, with instant marking and a mark scheme

    Start today's paper
Read next
Maths · StatisticsGeometric distribution: formula, mean and examplesWhat the geometric distribution is, its formula, cumulative probabilities, mean and variance, how it differs from the binomial, and worked examples.