# Chi-square goodness of fit

This test asks whether observed counts match the counts a model predicts. The statistic is the sum of (observed - expected) squared / expected, with k - 1 degrees of freedom for k categories.

Statistics (university) · Part 07: Comparing categories and many groups · Card 1 of 8 · Last updated 2026-10-19

## Analogy

Checking a die by rolling it many times and comparing each face's count with the fair share.

## Example

**Is the die fair?**

60 rolls, expected 10 per face
Observed: 5, 8, 9, 8, 10, 20
Sum of (O-E)^2/E
= (25+4+1+4+0+100)/10 = 13.4
df = 5, critical 11.07, p = 0.02

## In practice

Tests whether sales are equal across days, or whether genetics data follow a predicted ratio.

## Practice

### Flashcards

- **Chi-square statistic formula?** Sum of (observed - expected) squared / expected.

## Questions people ask

### How do I read the chi-square statistic?

Each term measures how far a count is from its expected value, scaled by that expected value. A large total means the data is far from the model. Compare it with the chi-square distribution for the right degrees of freedom to get a p-value.

### Can the chi-square statistic be negative?

No. Every term is a squared difference divided by a positive expected count, so the sum is zero or larger. Zero means the observed counts match the expected exactly. Larger values mean worse fit, so only the upper tail matters.

## Related concepts

- [Expected counts](https://studyvisually.com/learn/science/statistics-university/statistics-university-part-7/statistics-university-part-7-concept-2)
- [Chi-square test of independence](https://studyvisually.com/learn/science/statistics-university/statistics-university-part-7/statistics-university-part-7-concept-3)

Web page: https://studyvisually.com/learn/science/statistics-university/statistics-university-part-7/statistics-university-part-7-concept-1
Study this card in the app: https://studyvisually.com/app/learn?category=statistics-university&card=statistics-university-part-7-concept-1
