Discrete Uniform

X∼U{a,…,b}X \sim \mathcal{U}\{a, \dots, b\}

Every whole number from a to b is equally likely. It is the mathematical form of a perfectly fair die.

The story

When you have no reason to favour any outcome over another, you give them all the same probability. With m=b−a+1m = b - a + 1 possible values, each one gets probability 1/m1/m, and the PMF is a flat row of equal bars.

The mean sits exactly in the middle at (a+b)/2(a + b)/2, and the variance is (m2−1)/12(m^2 - 1)/12, which grows with the width of the range. For a standard die (a=1a = 1, b=6b = 6) that gives a mean of 3.5, a value the die can never actually show, and a variance of 35/12≈2.9235/12 \approx 2.92.

Formulas

Support

k∈{a,a+1,…,b}k \in \{a, a + 1, \ldots, b\}

PMF

P(X=k)=1b−a+1P(X = k) = \frac{1}{b - a + 1}

CDF

F(k)=⌊k⌋−a+1b−a+1F(k) = \frac{\lfloor k \rfloor - a + 1}{b - a + 1}

Expectation

E[X]=a+b2\mathbb{E}[X] = \frac{a + b}{2}

Variance

Var⁡(X)=(b−a+1)2−112\operatorname{Var}(X) = \frac{(b - a + 1)^2 - 1}{12}

Parameters

ParameterWhat it controls
aaThe smallest possible value (inclusive). Keep it no larger than bb.
bbThe largest possible value (inclusive). Together with aa it fixes the number of outcomes, b−a+1b - a + 1, and so the probability of each.

Where it shows up

  • The score on a single roll of a fair die.
  • A random index chosen to pick an element from a list.
  • The last digit of a randomly chosen phone number.
  • Assigning participants at random to one of several equally sized groups.

Try this

  1. Set a=1a = 1 and b=6b = 6 to build a die. Press Draw 100 a few times and notice how uneven the histogram looks; then press Draw 1000 and watch it flatten out.
  2. Keeping the die, switch to Sample means with n=2n = 2. The histogram of averages forms a triangle peaking at 3.5, exactly like the familiar totals of two dice. Raise nn to 10 and it rounds into a bell.
  3. Set a=0a = 0 and b=20b = 20 and shade the interval from 5 to 9. With 21 equally likely values, the shaded probability is 5/21≈0.2385/21 \approx 0.238: in a flat distribution, probability is simply a matter of counting.

Related distributions

  • The Bernoulli with p=0.5p = 0.5 is the Discrete Uniform on {0,1}\{0, 1\}.
  • It is the whole-number counterpart of the continuous Uniform on [a,b][a, b]; as the grid of values gets finer, the two behave alike.
  • Averages of many independent draws are approximately Normal by the Central Limit Theorem, even though a single draw is completely flat.