Exam PDiscreteFree to read

Discrete uniform distribution

A finite set of equally likely integer outcomes, such as one fair die.

Parameters and support

aa
smallest value in the support - a∈Za \in \mathbb{Z}
bb
largest value in the support - b≥ab \ge a
Support
x∈{a, a+1, …, b}x \in \{a,\, a+1,\, \dots,\, b\}

The formulas

p(x)
p(x)=1b−a+1p(x) = \dfrac{1}{b-a+1}
F(x)
F(x)=⌊x⌋−a+1b−a+1,a≤x≤bF(x) = \dfrac{\lfloor x \rfloor - a + 1}{b-a+1}, \quad a \le x \le b
Mean
E[X]=a+b2E[X] = \dfrac{a+b}{2}
Variance
Var⁡(X)=(b−a+1)2−112\operatorname{Var}(X) = \dfrac{(b-a+1)^2 - 1}{12}
MGF
M(t)=eat(ent−1)n(et−1),n=b−a+1M(t) = \dfrac{e^{at}\left(e^{n t} - 1\right)}{n\left(e^{t} - 1\right)}, \quad n = b-a+1
Memory hook. The mean is the midpoint, and the variance is (n² − 1)/12 where n is the COUNT of values, not the range. A fair die has n = 6, so Var = 35/12 - not 25/12.

Where the moments come from

  1. Shift the support to {1,2,…,n}\{1, 2, \dots, n\} with n=b−a+1n = b-a+1; shifting changes the mean by a constant and leaves the variance alone.
  2. E[X]=1n∑k=1nk=n+12E[X] = \frac{1}{n}\sum_{k=1}^{n} k = \frac{n+1}{2} using the arithmetic-series sum.
  3. E[X2]=1n∑k=1nk2=(n+1)(2n+1)6E[X^2] = \frac{1}{n}\sum_{k=1}^{n} k^2 = \frac{(n+1)(2n+1)}{6} using the sum of squares.
  4. Var⁡(X)=(n+1)(2n+1)6−(n+12)2=n2−112\operatorname{Var}(X) = \frac{(n+1)(2n+1)}{6} - \left(\frac{n+1}{2}\right)^2 = \frac{n^2-1}{12}.
  5. Shifting back adds a−1a-1 to the mean and leaves the variance unchanged.

Worked example

A fair six-sided die is rolled once. Find the variance of the number showing.

  1. The support is {1,2,3,4,5,6}\{1,2,3,4,5,6\}, so n=6−1+1=6n = 6 - 1 + 1 = 6 values.
  2. Var⁡(X)=n2−112=36−112=3512\operatorname{Var}(X) = \dfrac{n^2 - 1}{12} = \dfrac{36 - 1}{12} = \dfrac{35}{12}.
  3. As a decimal that is 2.91672.9167.

Answer: 35/12 ≈ 2.9167

The mean, variance, CDF and moment generating function above are re-derived numerically from this distribution’s own density on every test run - summed over the support for a discrete distribution, integrated by quadrature for a continuous one - and compared with the closed forms printed here. A typo on this page fails that test run.

Traps

  • Using the range b − a instead of the count b − a + 1 in the variance.
  • Assuming the variance formula (n² − 1)/12 applies to a CONTINUOUS uniform - there it is (b − a)²/12.

Related

Drill this: the Exam P question bank has original questions on this distribution, and the recall trainer builds its prompts from exactly the formulas above.