Statistics · Unit 3 · Week 9 · Lesson 29 · 11 minute reading

Is This Die Playing by the Rules?

Expected categorical counts, chi-square goodness-of-fit tests, and reference distributions.

By the end of this lesson, you should be able to

  • Compute expected counts under a categorical null.
  • Calculate Pearson's goodness-of-fit statistic.
  • Check sampling and expected-count assumptions.

We roll a supposedly fair six-sided die 60 times and record counts of [15,5,10,10,10,10][15,5,10,10,10,10].

The counts are not all ten. Does this mean the die is crooked? If we have learned anything by now, it should be that random variation makes observed counts unequal even when the probabilities are equal.

Calculate the discrepancy

Under a fair independent-roll model each face has probability 1/61/6. The expected count per face is 60/6=1060/6=10.

Pearson’s goodness-of-fit statistic is

X2=∑i=1k(Oi−Ei)2Ei.X^2=\sum_{i=1}^{k}\frac{(O_i-E_i)^2}{E_i}.

The first two cells contribute (15−10)2/10=2.5(15-10)^2/10=2.5 and (5−10)2/10=2.5(5-10)^2/10=2.5. The rest contribute zero. Thus X2=5X^2=5.

With six categories and a fully specified null distribution, the conventional asymptotic reference is chi-square with k−1=5k-1=5 degrees of freedom.

We can then calculate an upper-tail p-value. The statistic itself is not a probability.

Assumptions govern the reference distribution

The observations need an appropriate independent categorical sampling model. The categories must be exhaustive and mutually exclusive.

If expected cell counts are very small, the chi-square approximation can perform poorly, and exact or simulation-based alternatives may be preferable.

If we estimate model parameters from the same counts, the degrees of freedom may change. Don’t simply subtract one without considering the fitted parameters.

A software check

observed <- c(15,5,10,10,10,10)
chisq.test(observed,p=rep(1/6,6))

Read the expected counts, statistic, degrees of freedom, and assumptions together.

Check your understanding

  1. Under five equally probable categories and 100 observations, what is the expected count per category?
  2. Why does X2=0X^2=0 not prove a distribution is exactly fair?
  3. Why can sparse expected cells undermine the chi-square approximation?
Worked responses
  1. Perfect agreement in one sample does not establish the population model.

  2. The continuous asymptotic reference may poorly approximate the discrete small-sample distribution.

From counts to a model-based decision

For the die example, the upper-tail reference probability is P(χ52≥5)≈0.41588P(\chi^2_5\geq5)\approx0.41588. At a prespecified 5% threshold, this is not evidence sufficient to reject the uniform probability model. It is not a 41.6% probability that the die is fair. The probability describes discrepancies under the null model, not posterior odds among possible dice.

The counts obey a constraint: once five category counts and the total are known, the sixth is determined. That explains the five degrees of freedom for six fully specified probabilities. If parameters are estimated from these same data, the familiar k−1−mk-1-m adjustment requires a regular fitted-model setting with mm effective estimated parameters; it is not an unconditional subtraction rule for arbitrary adaptive models or category choices.

A single cell’s contribution can identify where discrepancies arise, but the global p-value concerns the sum. In this example the first two faces contribute the entire statistic, 2.52.5 each. Investigating them after seeing the table is exploratory. A follow-up claim about a particular face needs an appropriately specified comparison, especially if all six are searched.

For sparse categories, one option is to simulate many independent multinomial samples under the prespecified null and compare their statistics with the observed statistic. In a Monte Carlo test, (b+1)/(B+1)(b+1)/(B+1), where bb simulated values are at least as extreme among BB draws, avoids reporting an impossible zero simulated p-value and has a randomized-rank justification under the null. Record the random seed, repetition count, and Monte Carlo uncertainty. Pool categories only when substantively defensible, not to manufacture significance.

Additional practice

  1. With observed counts [12,8][12,8] and equal null probabilities, find expected counts, the statistic, and degrees of freedom.
  2. Why is the rejection region in the upper tail even when some observed cells are below expectation?
  3. Can a large sample make a small departure statistically detectable but practically unimportant?
Worked additional solutions
  1. Expected counts are [10,10][10,10], giving X2=4/10+4/10=0.8X^2=4/10+4/10=0.8 and one degree of freedom.
  2. Squaring converts both upward and downward deviations into positive discrepancy contributions. Larger totals indicate poorer agreement.
  3. Yes. Report observed proportions and substantive departures along with the statistic and p-value.
Your study progress · Optional

Keep your place

Mark this lesson complete after you've read it, attempted its exercises, and explained its central idea in your own words.

Progress is not saved unless you choose to mark the lesson complete.

Saved only in this browser's local storage. No required account, server transmission, or analytics. You can reset your saved progress on the course page. Clearing browser data also clears the record.