Probability · interactive laboratory

Chi-square test laboratory

Are the observed frequencies close enough to those predicted by a hypothesis? The chi-square test measures the discrepancies, but its conclusion depends on precise conditions.

Back to the distribution laboratory

The question the test asks

The null hypothesis H₀ assigns a probability to each category before the sample is observed. H₁ says the distribution does not follow those probabilities. For each category we calculate the expected frequency E = N × p, then add the weighted discrepancies.

χ² = Σ (O − E)² / E

When the result is valid

Observations must be independent, categories mutually exclusive and exhaustive, and every expected frequency at least 5. If a category is too small, combine it with an adjacent category before testing.

Here the theoretical probabilities are fixed independently of the data. In the Poisson example, λ = 2 is specified beforehand, not estimated from the sample. If you estimate parameters from the same data, the degrees of freedom change and this p-value calculation does not apply directly.

Try your own data

One line per category: name; observed count; theoretical probability. You can use 1/6 or 0.166667. The probabilities must sum to 1; small rounding differences are allowed.

Further reading: NIST: chi-square goodness-of-fit test.