Unit 6, lesson 37

The Discrete Uniform Distribution

How a discrete uniform distribution puts equal mass on a finite set of values, how to count support values and events, and how symmetry and the sum-of-squares identity give the mean and variance of consecutive integers.

  • Video 37
  • Uniform and Bernoulli Distributions

A fair die is modeled by giving each face from 11 to 66 the same probability, and a raffle that draws one ticket uniformly from tickets numbered 11 to 500500 gives each number the same chance. In both models the probability of an event comes from counting values. The average result and the typical distance from it still take some work. This lesson defines equal mass on a finite set of values, derives the mean and variance for consecutive integers from aa to bb, and shows which parts of those formulas fail when the values are unevenly spaced.

Key terms

Discrete uniform distribution

Definition Let SS be a finite nonempty set of NN distinct real numbers. A random variable XX has the discrete uniform distribution on SS if its PMF is

pX(x)={1N,x∈S,0,otherwise.p_X(x) = \begin{cases} \tfrac{1}{N}, & x \in S, \\[0.3em] 0, & \text{otherwise}. \end{cases}

Then SS is the support of XX, and for every set AA of real numbers

P(X∈A)=∣A∩S∣N,P(X \in A) = \frac{\lvert A \cap S \rvert}{N},

where ∣A∩S∣\lvert A \cap S \rvert is the number of support values that lie in AA. The support has to be finite. No distribution on the positive integers gives every positive integer the same probability, because a common mass c>0c > 0 makes the total infinite and the mass c=0c = 0 makes the total 00.

In plain words Every listed value gets the same share of probability, and anything not listed gets none. The equal shares belong to the values of XX, not to physical objects. A die with faces 11, 11, 22, 33, 44 and 55 has six equally likely faces, but the number it shows equals 11 with probability 13\tfrac{1}{3}, so that number is not uniform on {1,2,3,4,5}\{1, 2, 3, 4, 5\}.

Example A selection device picks one of the labels 22, 33, 44, 55 and 66, each with probability 15\tfrac{1}{5}, and XX is the label. The event X≥4X \ge 4 contains the three values 44, 55 and 66, so P(X≥4)=35P(X \ge 4) = \tfrac{3}{5}. The event X>4X > 4 contains only 55 and 66, so P(X>4)=25P(X > 4) = \tfrac{2}{5}. Equal masses turn every event into a counting problem, but the wording of the event still decides which values are counted.

Number of support values

Definition For integers a≤ba \le b, the set of consecutive integers {a,a+1,…,b}\{a, a + 1, \dots, b\} contains

N=b−a+1N = b - a + 1

values, since both endpoints are included. A discrete uniform variable on this set gives each value the mass 1N\tfrac{1}{N}, and an event that contains exactly mm of the support values has probability mN\tfrac{m}{N}.

In plain words Count the values, not the gaps between them. Going from aa to bb takes b−ab - a steps of size 11, and there is one more value than there are steps, for the same reason that a fence with four gaps needs five posts.

Example The labels from 22 to 66 give N=6−2+1=5N = 6 - 2 + 1 = 5 values, with 44 gaps between neighbors. The integers from −3-3 to 33 give N=3−(−3)+1=7N = 3 - (-3) + 1 = 7 values, so each has mass 17\tfrac{1}{7}. Using b−a=6b - a = 6 instead would give each of the seven values the mass 16\tfrac{1}{6}, and the masses would add to 76\tfrac{7}{6}.

Mean by symmetry

Definition For a discrete uniform variable on a finite set SS with NN values, the mean is the plain average of the support values,

E[X]=1N∑x∈Sx.E[X] = \frac{1}{N} \sum_{x \in S} x.

If SS is symmetric about a number cc, meaning that x∈Sx \in S exactly when 2c−x∈S2c - x \in S, then E[X]=cE[X] = c. The reason is that XX and 2c−X2c - X have the same distribution, so E[X]=E[2c−X]=2c−E[X]E[X] = E[2c - X] = 2c - E[X]. A set of consecutive integers from aa to bb is symmetric about its midpoint, so

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

In plain words When the support is symmetric, pair the smallest value with the largest, the second smallest with the second largest, and so on. Each pair balances at the same midpoint, and with equal masses no pair pulls harder than another. When NN is odd, the unpaired middle value is the midpoint itself. The mean need not be a possible value of XX.

Example For the labels 22 to 66, the pair 22 and 66 and the pair 33 and 55 both balance at 44, and the middle value is 44. So E[X]=4E[X] = 4, in agreement with (2+6)/2(2 + 6)/2 and with the direct average 20/520/5. Now let XX be uniform on {2,4,7,11}\{2, 4, 7, 11\}. This is still a discrete uniform distribution, with each mass 14\tfrac{1}{4}, but its support is not symmetric. Its mean is 24/4=624/4 = 6, while the midpoint of the endpoints is 6.56.5.

Sum-of-squares identity

Definition For every positive integer NN,

∑k=1Nk2=N(N+1)(2N+1)6.\begin{aligned} &\sum_{k=1}^{N} k^2 \\[0.4em] &\quad = \frac{N(N + 1)(2N + 1)}{6}. \end{aligned}

One proof adds the identities (k+1)3−k3=3k2+3k+1(k + 1)^3 - k^3 = 3k^2 + 3k + 1 for k=1,…,Nk = 1, \dots, N. The left sides telescope to (N+1)3−1(N + 1)^3 - 1. The right sides add to 3∑k=1Nk2+32N(N+1)+N3\sum_{k=1}^{N} k^2 + \tfrac{3}{2}N(N + 1) + N, using the sum of the first NN positive integers. Solving the resulting equation for the sum of squares gives the formula.

In plain words This is an algebra fact about finite sums, not a probability assumption. Probability enters when the squares are averaged with equal weights. For KK uniform on {1,2,…,N}\{1, 2, \dots, N\} the identity gives the second moment

E[K2]=(N+1)(2N+1)6.E[K^2] = \frac{(N + 1)(2N + 1)}{6}.

Example For N=5N = 5 the squares 11, 44, 99, 1616 and 2525 add to 5555, and the formula gives 5⋅6⋅11/6=555 \cdot 6 \cdot 11 / 6 = 55. A variable KK uniform on {1,2,3,4,5}\{1, 2, 3, 4, 5\} therefore has E[K2]=55/5=11E[K^2] = 55/5 = 11. With E[K]=3E[K] = 3, its variance is 11−32=211 - 3^2 = 2.

Variance of consecutive integers

Definition Let a≤ba \le b be integers, let N=b−a+1N = b - a + 1, and let XX be uniform on {a,a+1,…,b}\{a, a + 1, \dots, b\}. Then

Var⁡(X)=N2−112,\operatorname{Var}(X) = \frac{N^2 - 1}{12},

and SD⁡(X)=(N2−1)/12\operatorname{SD}(X) = \sqrt{(N^2 - 1)/12}. To derive this, first take KK uniform on {1,2,…,N}\{1, 2, \dots, N\}, with E[K]=(N+1)/2E[K] = (N + 1)/2 and E[K2]E[K^2] from the sum-of-squares identity. Then the variance of KK is

E[K2]−(E[K])2=(N+1)(2N+1)6−(N+1)24=N2−112.\begin{aligned} &E[K^2] - (E[K])^2 \\[0.4em] &\quad = \frac{(N + 1)(2N + 1)}{6} \\[0.4em] &\qquad - \frac{(N + 1)^2}{4} \\[0.4em] &\quad = \frac{N^2 - 1}{12}. \end{aligned}

Over the common denominator 1212 the numerator is (N+1)(2(2N+1)−3(N+1))=(N+1)(N−1)(N + 1)\bigl(2(2N + 1) - 3(N + 1)\bigr) = (N + 1)(N - 1). The variable XX has the same distribution as K+(a−1)K + (a - 1), and adding a constant leaves the variance unchanged. The formula assumes consecutive integers with equal masses. For N=1N = 1 it gives 00, as it should for a variable with one possible value.

In plain words The spread depends only on how many consecutive values there are, not on where the block of values sits on the number line. Sliding the block moves the mean and leaves the variance alone.

Example For the labels 22 to 66, N=5N = 5 and the formula gives (25−1)/12=2(25 - 1)/12 = 2. The direct check uses the squared deviations from the mean 44, which are 44, 11, 00, 11 and 44. Their average is 10/5=210/5 = 2, so Var⁡(X)=2\operatorname{Var}(X) = 2 squared label units and SD⁡(X)=2≈1.41\operatorname{SD}(X) = \sqrt{2} \approx 1.41 label units. Equal probabilities do not mean zero spread.

Evenly spaced support

Definition A finite set is evenly spaced with gap d>0d > 0 if it has the form {c,c+d,…,c+(N−1)d}\{c, c + d, \dots, c + (N - 1)d\}. If XX is uniform on such a set, then J=(X−c)/dJ = (X - c)/d is uniform on {0,1,…,N−1}\{0, 1, \dots, N - 1\}, because the map is one-to-one, and X=c+dJX = c + dJ. Hence

E[X]=c+(N−1)d2,Var⁡(X)=d2(N2−1)12.\begin{gathered} E[X] = c + \frac{(N - 1)d}{2}, \\[0.4em] \operatorname{Var}(X) = \frac{d^2 (N^2 - 1)}{12}. \end{gathered}

The mean is the midpoint of the smallest and largest values, and SD⁡(X)=d(N2−1)/12\operatorname{SD}(X) = d\sqrt{(N^2 - 1)/12}. For a support that is not evenly spaced, the mean and variance are computed directly from the support values.

In plain words Equal spacing makes the variable a rescaled copy of consecutive integers, so the formulas carry over with the gap as the unit of length. The variance scales by d2d^2 and the standard deviation by dd. Equal masses survive any one-to-one relabeling, but a function that merges values need not keep them equal. If XX is uniform on {−1,0,1}\{-1, 0, 1\}, then X2X^2 equals 11 with probability 23\tfrac{2}{3}, so it is not uniform on {0,1}\{0, 1\}.

Example The set {1,3,5,7}\{1, 3, 5, 7\} has c=1c = 1, d=2d = 2 and N=4N = 4, so E[X]=1+3=4E[X] = 1 + 3 = 4 and Var⁡(X)=4⋅15/12=5\operatorname{Var}(X) = 4 \cdot 15/12 = 5. Directly, the squared deviations 99, 11, 11 and 99 average to 55. The set {2,4,7,11}\{2, 4, 7, 11\} has gaps 22, 33 and 44, so the shortcut formulas do not apply. From its mean 66 the deviations are −4-4, −2-2, 11 and 55, and

Var⁡(X)=16+4+1+254=232.\begin{aligned} \operatorname{Var}(X) &= \frac{16 + 4 + 1 + 25}{4} \\[0.4em] &= \frac{23}{2}. \end{aligned}

The consecutive-integer formula with N=4N = 4 would give 54\tfrac{5}{4}, far too small.

Check yourself

  1. Let XX be an integer chosen uniformly from −3-3 through 33, both endpoints included. How many support values are there, what is the mass of each, and what is P(∣X∣≤1)P(\lvert X \rvert \le 1)?
Show the answer

The support is −3-3, −2-2, −1-1, 00, 11, 22 and 33, so N=3−(−3)+1=7N = 3 - (-3) + 1 = 7 and each value has mass 17\tfrac{1}{7}. The event ∣X∣≤1\lvert X \rvert \le 1 contains the three values −1-1, 00 and 11, so its probability is 37\tfrac{3}{7}.

  1. For the same XX, find E[X]E[X] and Var⁡(X)\operatorname{Var}(X), once with the consecutive-integer formulas and once directly.
Show the answer

The formula gives E[X]=(a+b)/2=(−3+3)/2=0E[X] = (a + b)/2 = (-3 + 3)/2 = 0. Directly, the seven values add to 00, so their average is 00, as the symmetry of the support about 00 also shows. The variance formula gives (72−1)/12=48/12=4(7^2 - 1)/12 = 48/12 = 4. Directly, the squared deviations from 00 are 99, 44, 11, 00, 11, 44 and 99. They add to 2828, and 28/7=428/7 = 4.

  1. With the same XX, let Y=X2Y = X^2. A student says that YY is uniform on {0,1,4,9}\{0, 1, 4, 9\} and concludes that E[Y]=14/4=3.5E[Y] = 14/4 = 3.5. Find the correct PMF of YY and the correct E[Y]E[Y].
Show the answer

The value 00 comes only from X=0X = 0, while each of 11, 44 and 99 comes from two values of XX. So P(Y=0)=17P(Y = 0) = \tfrac{1}{7} and P(Y=1)=P(Y=4)=P(Y=9)=27P(Y = 1) = P(Y = 4) = P(Y = 9) = \tfrac{2}{7}, which is not uniform. Then

E[Y]=0+2+8+187=4.\begin{aligned} E[Y] &= \frac{0 + 2 + 8 + 18}{7} \\[0.4em] &= 4. \end{aligned}

This agrees with the previous answer, as it must. Because E[X]=0E[X] = 0, the shortcut Var⁡(X)=E[X2]−(E[X])2\operatorname{Var}(X) = E[X^2] - (E[X])^2 gives E[Y]=E[X2]=Var⁡(X)=4E[Y] = E[X^2] = \operatorname{Var}(X) = 4.

How this lesson connects

It also uses the sum of the first n positive integers.