The Discrete Uniform Distribution
Roll a fair die and every face — 1 through 6 —
has exactly the same chance. Spin a fair spinner split into equal sectors: no sector is favoured.
Pull a raffle ticket from a well-shaken drum, or ask a computer for a random whole number between
1 and n: again, nothing is special, everything
is equally likely. That single idea — a fixed list of outcomes, all with
the same probability — is the discrete uniform distribution. It is the
distribution
of fairness itself.
"Discrete" means the outcomes come in separate, countable lumps (the numbers on a die, not every
temperature on a thermometer). "Uniform" means the probability is spread out evenly. If
there are n outcomes, each one has to carry a share of
\tfrac{1}{n} of the total probability — because they are
equally likely
and, together, they must add up to 1.
P(X = k) = \frac{1}{n} \qquad \text{for each } k = 1, 2, \ldots, n.
We write X \sim U\{1, 2, \ldots, n\} to say "X
is uniform on the whole numbers from 1 to n".
Check the total: n outcomes, each worth
\tfrac{1}{n}, give n \times \tfrac{1}{n} = 1.
Perfect.
Every one of them is a discrete uniform distribution wearing a different costume. A fair coin is
U\{1, 2\} (heads = 1, tails =
2). A fair die is U\{1, \ldots, 6\}. A month
picked at random is U\{1, \ldots, 12\}. A shuffled deck cut to a random
card, a lottery ball, the Math.random() integer a game uses to pick a level — all the
same flat shape underneath. Learn this one distribution and you have met the honest heart of every
game of chance.
The flat picture
Draw the distribution as a bar chart — one bar per outcome, its height the probability
P(X = k) — and you get the most recognisable shape in all of statistics:
a perfectly flat row of bars, every one at height
\tfrac{1}{n}. No peak, no tail, no lean. That flatness is the
distribution: it is exactly what "equally likely" looks like when you draw it.
Notice what happens as n grows. There are more bars, but each is
shorter — the same slab of probability, 1, is sliced into
more, thinner pieces. A fair die's bars sit at \tfrac{1}{6} \approx 0.167;
a 20-sided die's bars sit at \tfrac{1}{20} = 0.05.
Its mean and spread
Where is the "middle" of a flat row of bars? Right in the centre. The outcomes
1, 2, \ldots, n are evenly spaced and equally weighted, so their balance
point — the mean — is simply the average of the first and last:
\mu = \frac{1 + n}{2} = \frac{n + 1}{2}.
The variance measures how far the outcomes spread from that centre. For the discrete
uniform on 1, \ldots, n it works out to a tidy closed form:
\sigma^{2} = \frac{n^{2} - 1}{12}.
Both grow in the obvious direction: a die with more faces has a higher average score and a wider
spread. Notice the 12 lurking in the variance — the same
12 that shows up all over uniform-distribution algebra.
It comes from a sum you may have met: the squares
1^2 + 2^2 + \cdots + n^2 = \tfrac{n(n+1)(2n+1)}{6}. Feed that into the
definition \sigma^2 = E[X^2] - \mu^2, simplify, and the sixes and twos
collapse into a single \tfrac{n^2 - 1}{12}. The continuous cousin (a
uniform spread over an interval of width w) has variance
\tfrac{w^2}{12} — the very same 12. It is a
fingerprint of flatness.
Worked example 1 — a fair six-sided die
Roll one ordinary die and let X be the number on top. There are
n = 6 equally likely faces, so
P(X = 1) = P(X = 2) = \cdots = P(X = 6) = \frac{1}{6} \approx 0.167.
The mean score is
\mu = \frac{n + 1}{2} = \frac{6 + 1}{2} = 3.5,
and the variance is
\sigma^{2} = \frac{n^{2} - 1}{12} = \frac{36 - 1}{12} = \frac{35}{12} \approx 2.92,
which gives a standard deviation of
\sigma = \sqrt{35/12} \approx 1.71. So over many rolls the scores average
3.5 and typically land within about
1.7 of that.
Worked example 2 — a fair four-sector spinner
A board-game spinner is divided into 4 equal sectors labelled
1, 2, 3, 4. Because the sectors are the same size, spinning it is
U\{1, 2, 3, 4\}, so every sector's probability is
P(X = k) = \frac{1}{4} = 0.25 \quad \text{for } k = 1, 2, 3, 4.
The mean sector number is
\mu = \frac{n + 1}{2} = \frac{4 + 1}{2} = 2.5.
As a sanity check we can also average the outcomes directly:
\tfrac{1}{4}(1 + 2 + 3 + 4) = \tfrac{10}{4} = 2.5. The formula and the
long way agree — as they always must.
See it: the flat bar chart
Drag the slider to change n, the number of equally likely outcomes. Two
things happen at once, and they are the whole story of this distribution:
- the bars stay exactly level — there is never a peak, because no outcome is
favoured;
- every bar's height is \tfrac{1}{n}, so more outcomes means
shorter bars (the readout tracks the value).
- "Uniform" means equal probability, not equal values. The
outcomes of a die — 1, 2, 3, 4, 5, 6 — are all different; what is the
same is the chance of each. Do not confuse a flat bar chart of probabilities with the
outcomes themselves being identical.
- The mean need not be a possible outcome. A fair die's mean is
\tfrac{n+1}{2} = 3.5 — a score the die can never actually
show. The average is a balance point, not a face. It is fine, and normal, for the "average
outcome" to be impossible.
- Every outcome must be genuinely equally likely. A loaded die or a
spinner with unequal sectors is not uniform — the bars would no longer be
level, and none of these formulas apply.
If X \sim U\{1, 2, \ldots, n\} — n equally likely outcomes — then:
- Probabilities (PMF): P(X = k) = \dfrac{1}{n} for every k = 1, \ldots, n — a perfectly flat bar chart.
- Mean: \mu = \dfrac{n + 1}{2}.
- Variance: \sigma^{2} = \dfrac{n^{2} - 1}{12}.