Tutorials › VEE Mathematical Statistics › Deriving the Variance of a Consecutive Discrete Uniform Variable

VEE Mathematical Statistics · Hypergeometric and Discrete Uniform Models · Tutorial 142 of 880

Deriving the Variance of a Consecutive Discrete Uniform Variable

Learn why the variance depends only on the number of consecutive integer values and how to calculate and interpret it.

Intermediate 10 min read

What You'll Learn

  • State the assumptions for a discrete uniform distribution on consecutive integers
  • Derive the variance by summing squared deviations from the mean
  • Express the result using the number of values in the support
  • Verify the formula with direct calculations for small supports
  • Distinguish the variance of a distribution from a sample variance
  • Use the variance to calculate standard deviations and related probabilities

Why the Variance Depends on the Support Size

A discrete uniform variable on consecutive integers assigns equal probability to each value in a finite run of integers. Its mean lies at the center of that run, but the variance requires more than knowing the center: it measures the average squared distance from the center. Deriving the variance from those squared distances shows exactly how the spread depends on the number of possible values.

This result is aligned with the SOA VEE Mathematical Statistics syllabus. The key is to use the variance of the specified probability distribution, not the sample-variance formula used to summarize observed data.

Definition: Let \(X\) have a discrete uniform distribution on the \(n\) consecutive integers \(a,a+1,\ldots,a+n-1\), where \(a\) is an integer and \(n\) is a positive integer. Each value has probability \(1/n\). The support size is \(n\), the number of possible values. The variance is the probability-weighted average of squared deviations from the mean: $$ \operatorname{Var}(X)=E[(X-E[X])^2]. $$

The earlier material on the mean of a consecutive discrete uniform variable gives \(E[X]=a+(n-1)/2\). We will use that result and derive the variance directly from its definition. The calculation works for \(n=1\) as well: if only one value is possible, there is no spread and the variance is zero.

Deriving the Variance by Summing Squared Deviations

Index the support values by writing \(X=a+j\), where \(j\) runs from \(0\) through \(n-1\). The mean is \(a+(n-1)/2\), so the deviation of the value \(a+j\) from the mean is \(j-(n-1)/2\). Each of the \(n\) deviations has probability \(1/n\).

$$ \operatorname{Var}(X) =\frac{1}{n}\sum_{j=0}^{n-1}\left(j-\frac{n-1}{2}\right)^2 $$

To evaluate the sum, expand the square. The required finite sums are \(\sum_{j=0}^{n-1}j=n(n-1)/2\) and \(\sum_{j=0}^{n-1}j^2=n(n-1)(2n-1)/6\). The first identity follows by pairing the first and last terms, the second and next-to-last terms, and so on. For the square-sum identity, sum \((j+1)^3-j^3=3j^2+3j+1\) from \(j=0\) to \(n-1\); the left side telescopes to \(n^3\). Substituting the first-sum identity and solving for the sum of squares gives the stated formula.

$$ \begin{aligned} \sum_{j=0}^{n-1}\left(j-\frac{n-1}{2}\right)^2 &=\sum_{j=0}^{n-1}j^2 -(n-1)\sum_{j=0}^{n-1}j +n\frac{(n-1)^2}{4}\\ &=\frac{n(n-1)(2n-1)}{6} -\frac{n(n-1)^2}{2} +\frac{n(n-1)^2}{4}\\ &=n(n-1)\left(\frac{2n-1}{6}-\frac{n-1}{2}+\frac{n-1}{4}\right)\\ &=\frac{n(n-1)(n+1)}{12}. \end{aligned} $$

The final step uses a common denominator of 12 inside the parentheses: \(2(2n-1)-6(n-1)+3(n-1)=n+1\). Dividing the total squared deviation by \(n\), because each support value has probability \(1/n\), gives the result.

Theorem: If \(X\) is discrete uniform on \(n\) consecutive integers, then $$ \operatorname{Var}(X)=\frac{(n-1)(n+1)}{12}=\frac{n^2-1}{12}. $$ The variance depends on the support size \(n\), not on the first integer \(a\).

The starting value disappears because it contributes equally to every possible value and to the mean; it therefore contributes nothing to their deviations. The formula also passes the \(n=1\) check: \((1^2-1)/12=0\). For \(n>1\), the variance is positive.

Worked Example: Directly Checking a Five-Value Support

A hypothetical random-number generator selects one of the integer settings \(2,3,4,5,6\), with every setting equally likely. Find the mean and variance, and verify the variance both by summing squared deviations and by using the support-size formula.

Method and assumptions. There are five consecutive settings, each with probability \(1/5\), so this is a discrete uniform variable with \(n=5\). The mean is the center of the support: $$ E[X]=\frac{2+6}{2}=4. $$

Direct calculation. The squared deviations from 4, in support order, are $$ (2-4)^2=4,\quad (3-4)^2=1,\quad (4-4)^2=0,\quad (5-4)^2=1,\quad (6-4)^2=4. $$ Their sum is \(4+1+0+1+4=10\). Since each value has probability \(1/5\), $$ \operatorname{Var}(X)=\frac{10}{5}=2. $$

Formula check. With \(n=5\), $$ \frac{n^2-1}{12}=\frac{25-1}{12}=\frac{24}{12}=2. $$ The two calculations agree. This direct check also illustrates the method: average the squared deviations, rather than summing them without dividing by the number of equally likely values.

Common mistake avoided: Dividing the squared-deviation sum by \(n-1=4\) would give \(10/4=2.5\). That is not the variance of this specified distribution; the probabilities require division by \(n=5\).

Using the Support-Size Formula

Once the model is identified and the number of support values is counted correctly, the formula is quick to apply. It is important that \(n\) counts possible integer values, not the numerical distance between the endpoints. For example, the integers from 4 through 11 have eight values, not seven.

Worked Example: An Eight-Value Setting With a Probability Check

A hypothetical device selects one integer setting from 4 through 11, with all settings equally likely. Find the mean and variance, then calculate the probability that the selected setting is at least 2.5 units from the mean.

Method and model check. The support contains \(11-4+1=8\) consecutive integers, so \(n=8\). The endpoints are symmetric around the mean: $$ E[X]=\frac{4+11}{2}=7.5. $$

Variance. Apply the support-size formula: $$ \operatorname{Var}(X)=\frac{8^2-1}{12} =\frac{64-1}{12} =\frac{63}{12} =\frac{21}{4} =5.25. $$

Probability calculation. The event is \(|X-7.5|\ge 2.5\). The settings satisfying it are 4, 5, 10, and 11: their distances from 7.5 are 3.5, 2.5, 2.5, and 3.5. Thus four of the eight equally likely settings qualify: $$ P(|X-7.5|\ge 2.5)=\frac{4}{8}=\frac{1}{2}. $$

Check. The mean is halfway between the endpoints, and the qualifying values occur in two matching pairs on opposite sides of it. The probability is therefore consistent with the symmetry of this support. The common counting trap is to use \(11-4=7\) as the support size; that would omit one endpoint and produce the wrong variance.

Variance, Standard Deviation, and Inclusive Boundaries

Variance is measured in squared units, while the standard deviation is its nonnegative square root and is measured in the original units. When using a standard deviation as a probability cutoff, retain enough precision to determine which integer values satisfy the event. Rounding a cutoff can change the included values when the support is discrete.

Worked Example: Squared Deviations and an Integer-Value Event

A hypothetical system chooses one integer label from 17 through 28, each with equal probability. Find the mean, variance, and standard deviation. Then calculate the probability that the chosen label is within 3.5 units of the mean, including values exactly 3.5 units away.

Method and assumptions. There are \(28-17+1=12\) equally likely consecutive integers, so \(n=12\). The mean is $$ E[X]=\frac{17+28}{2}=22.5. $$

Variance and standard deviation. $$ \operatorname{Var}(X)=\frac{12^2-1}{12} =\frac{143}{12} \approx 11.9167. $$ Therefore, $$ \operatorname{SD}(X)=\sqrt{\frac{143}{12}}\approx 3.452. $$ The variance is exact as \(143/12\); the decimal values shown are rounded to four decimal places for the variance and three for the standard deviation.

Probability. The specified cutoff is 3.5, so the event is \(|X-22.5|\le 3.5\), not an event with the exact standard deviation as its cutoff. The qualifying integers are 19 through 26 inclusive. There are \(26-19+1=8\) such values, each with probability \(1/12\): $$ P(|X-22.5|\le 3.5)=\frac{8}{12}=\frac{2}{3}. $$

Check and trap. The boundary values 19 and 26 are each exactly 3.5 from 22.5, so they are included by the stated “within 3.5” event. The exact standard deviation is approximately 3.452, which is less than 3.5; substituting that exact cutoff would give a different event. Always use the cutoff stated in the question and handle equality as specified.

Common Mistakes and What the Formula Does Not Say

  • Using the endpoint difference as \(n\). For integers from \(a\) through \(b\), inclusive, the support size is \(b-a+1\). Forgetting the \(+1\) changes the variance.
  • Using \(n-1\) in the denominator. The probability-weighted average divides the squared-deviation sum by \(n\), since there are \(n\) equally likely values. The sample-variance denominator \(n-1\) is a different calculation.
  • Confusing variance and standard deviation. The variance is \((n^2-1)/12\); the standard deviation is \(\sqrt{(n^2-1)/12}\).
  • Assuming every finite support is discrete uniform. The formula requires consecutive integer values with equal probabilities. If values have unequal probabilities, or the support is not a consecutive run of integers, this derivation does not apply as written.
  • Rounding a probability boundary too early. A rounded standard deviation may include or exclude a boundary integer differently from the exact value. Compare the integer deviations with the stated exact cutoff whenever possible.

The result is useful because it compresses a potentially long sum into one expression. For a support of \(n\) consecutive integers, the spread grows with \(n\), while the location of the support does not affect the variance. The formula is a consequence of equal weighting and the squared distances around the support’s center, not a general variance rule for arbitrary discrete variables.

Key takeaway: For a discrete uniform variable on \(n\) consecutive integers, sum the squared deviations from the mean and divide by \(n\). The resulting variance is \((n^2-1)/12\); count the support values inclusively and keep variance distinct from sample variance and standard deviation.

Check Your Understanding

For each problem, identify the support size before applying the formula. Treat endpoints as included and use equal probabilities only where the model says they are equal.

  1. A random integer is selected uniformly from \(0,1,2,3\). Find its variance. (Answer: \(15/12=1.25\).)
  2. A uniformly selected integer lies between 8 and 16 inclusive. Find the support size, mean, and variance. (Answer: \(n=9\), mean \(12\), variance \(80/12=20/3\).)
  3. A discrete uniform variable takes each value from \(-2\) through 4. Find its mean and variance by counting the support values. (Answer: \(n=7\), mean \(1\), variance \(48/12=4\).)
  4. A uniformly selected integer is from 10 through 21. Find its variance and the probability that it is within 3 units of its mean, including the boundary values. (Answer: variance \(143/12\); probability \(6/12=1/2\).)
  5. A uniformly selected integer is from 1 through 10. Find its variance and the probability that its distance from the mean is at least 3.5. (Answer: variance \(99/12=8.25\); probability \(4/10=0.4\).)
Clinical Biostats