Chi-Square Goodness-of-Fit Test
Learn how to test whether observed category counts fit an expected pattern. Change the data, adjust the probabilities, see the chi-square statistic, view the p-value, and practice the decision rule.
1. Big idea
A goodness-of-fit test answers one question: does the observed distribution fit the expected distribution?
Observed counts
These are the actual counts you collected from the sample.
Expected counts
These are the counts you would expect if the null hypothesis were true.
Decision
If the observed counts are too far from the expected counts, reject the null hypothesis.
2. Should you use this test?
Use the selector below to check whether chi-square goodness-of-fit is appropriate.
Test selection checker
Use it / do not use it
| Situation | Use GOF? | Why |
|---|---|---|
| Observed defect counts vs expected defect split | Yes | One categorical variable |
| Actual dice rolls vs fair die probabilities | Yes | Observed counts vs expected probabilities |
| Average tensile strength between two suppliers | No | That compares means |
| Relationship between defect type and shift | No | That is chi-square test of independence |
3. Live chi-square calculator
Edit the data. The table, chart, test statistic, degrees of freedom, p-value, and conclusion update automatically.
| Category | Observed O | Expected probability p | Expected E | O − E | (O − E)² / E | Action |
|---|
Observed vs expected chart
The bigger the gap between O and E, the larger the category contribution.
Chi-square distribution graph
The shaded right tail is the p-value area beyond your χ² statistic.
4. Degrees of freedom: specified vs estimated probabilities
The degrees of freedom depend on how the expected probabilities were obtained.
Specified probabilities
The expected probabilities are given before the sample is analyzed. You do not estimate any distribution parameter from the sample.
Example: A fair die has six specified probabilities: 1/6 for each side. Since k = 6, df = 6 − 1 = 5.
Degrees-of-freedom playground
5. Assumption checker
Before trusting the result, check the basic conditions.
Interactive checklist
Exam-ready notes
H₀: observed distribution follows the expected distribution. H₁: it does not.
Use Eᵢ = n pᵢ when probabilities are given.
Sum all category contributions.
Reject H₀ if p ≤ α or if χ²test > χ²critical.
6. Worked example with reveal steps
A factory expects four defect types to occur equally often. A sample of 100 defects gives the counts below.
Problem data
| Defect type | Observed | Expected p |
|---|---|---|
| Scratch | 35 | 0.25 |
| Dent | 20 | 0.25 |
| Crack | 30 | 0.25 |
| Wrong size | 15 | 0.25 |
Use α = 0.05.
Reveal the solution
7. Practice quiz
Answer each question and get immediate feedback. Use this as an exam review section.
8. Final summary card
Keep these points in mind when solving chi-square goodness-of-fit questions.
Statistic
χ² = Σ (O − E)² / E
Expected count
Eᵢ = n pᵢ
Degrees of freedom
Specified: df = k − 1
Estimated: df = k − 1 − m