The question the test answers
You roll a die 60 times and record how often each face lands. A fair die should give each face about 10 times, but you will almost never see exactly 10 of each. Some wobble is normal. The chi-square goodness-of-fit test asks a narrow question: if the die were truly fair, how likely is it that counts would stray this far from equal, or farther?
It does not tell you the die is loaded. It tells you whether the observed pattern is the sort of thing chance produces often or rarely.
The calculation
For each face, compare the observed count (O) with the expected count (E), then compute:
(O − E)² / E
Add those six numbers together. The total is the chi-square statistic. Squaring means over and under count equally, and dividing by E scales each gap to the size of the expected count.
A worked example
Say a 60-roll tally gives these counts for faces 1 to 6: 6, 8, 9, 11, 12, 14. They add to 60, so the expected count is 10 per face.
| Face | Observed | Expected | (O − E)² / E |
|---|---|---|---|
| 1 | 6 | 10 | 1.6 |
| 2 | 8 | 10 | 0.4 |
| 3 | 9 | 10 | 0.1 |
| 4 | 11 | 10 | 0.1 |
| 5 | 12 | 10 | 0.4 |
| 6 | 14 | 10 | 1.6 |
The statistic is 1.6 + 0.4 + 0.1 + 0.1 + 0.4 + 1.6 = 4.2.
Turning the statistic into a p-value
The statistic is compared with a chi-square distribution whose degrees of freedom equal the number of categories minus 1. A six-sided die has 5 degrees of freedom. A common reference point is that, with 5 degrees of freedom, a statistic above about 11.07 would occur by chance only around 5 percent of the time if the die were fair.
Our value, 4.2, is far below that. The p-value is roughly 0.5, meaning that about half the time a fair die would look at least this uneven. The tally looks unremarkable, even though the 6 appeared more than twice as often as the 1.
In a spreadsheet, with observed counts in B2:B7 and expected counts in C2:C7:
=CHISQ.TEST(B2:B7, C2:C7)
returns the p-value directly. Or, if you already have the statistic: =CHISQ.DIST.RT(4.2, 5). In Python, scipy.stats.chisquare([6, 8, 9, 11, 12, 14]) returns both the statistic and the p-value, assuming equal expected counts.
Reading the result sensibly
A small p-value, often below 0.05 by convention, means the data would be unusual for a fair die. It is a reason to look closer, not a verdict. A large p-value does not prove fairness either. It only says this sample gave no clear sign of a problem. A slightly loaded die can pass a 60-roll test easily, because there is simply not enough data to detect a small bias.
That connects to how much data is needed. As a rough rule, the test is only reliable when each expected count is at least about 5, so 60 rolls of a six-sided die is near the lower end of what is sensible. Hundreds of rolls make the test far more sensitive, and the broader question of how large a sample must be is covered under statistical significance.
Pitfalls
- Deciding the test after peeking. If you notice the 6 looks high and then test only the 6, you have chosen the question to fit the data. Test all faces together, or fix the plan beforehand.
- Running many tests. Check twenty dice at the 0.05 level and one will probably look loaded by chance alone.
- Sloppy rolling. A die thrown with a flat flick onto a soft surface can produce biased results with no fault in the die itself. Roll the same way each time and let it tumble.
- Counting errors. Make sure the observed counts add up to the number of rolls.
- Ignoring practical size. A statistically detectable bias can be too small to matter at the table. The test cannot tell you that.
When a test points to a problem
If a large, carefully rolled sample gives a very small p-value, repeat it with a fresh sample rather than relying on one result. Then check the die: uneven edges, bubbles and worn corners are plausible causes, though the test itself cannot name the cause. Casino dice are typically made to tight tolerances, while cheap novelty dice often are not, so a mild bias in the latter would not be surprising.
The same method works for any set of categories with known expected shares, such as checking whether a loot table seems to follow its published drop rates, or whether a shuffled deck puts suits in the proportions expected. The key ingredient is always a clear expected count under the “no problem” assumption. Without it the test has nothing to compare against.