UpSkill Sprint Consulting
Browse lessons
Interactive statistics lesson

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.

Example: 35 scratches, 20 dents, 30 cracks, 15 wrong-size defects.

Expected counts

These are the counts you would expect if the null hypothesis were true.

If each of 4 defect types should be equally likely and n = 100, each expected count is 25.

Decision

If the observed counts are too far from the expected counts, reject the null hypothesis.

This test is right-tailed because only large χ² values show poor fit.

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

SituationUse GOF?Why
Observed defect counts vs expected defect splitYesOne categorical variable
Actual dice rolls vs fair die probabilitiesYesObserved counts vs expected probabilities
Average tensile strength between two suppliersNoThat compares means
Relationship between defect type and shiftNoThat 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
χ² statistic0.000
df0
p-value—
critical value—
decision—

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.

Formula: df = k − 1

Example: A fair die has six specified probabilities: 1/6 for each side. Since k = 6, df = 6 − 1 = 5.

Degrees-of-freedom playground

df = 5 − 1 − 0 = 4

5. Assumption checker

Before trusting the result, check the basic conditions.

Interactive checklist

Exam-ready notes

1
State hypotheses.
H₀: observed distribution follows the expected distribution. H₁: it does not.
2
Compute expected counts.
Use Eᵢ = n pᵢ when probabilities are given.
3
Calculate χ².
Sum all category contributions.
4
Make the decision.
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 typeObservedExpected p
Scratch350.25
Dent200.25
Crack300.25
Wrong size150.25

Use α = 0.05.

Reveal the solution

1
Hypotheses
2
Expected counts
3
χ² statistic
4
Degrees of freedom
5
Conclusion

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

Decision rule: If p ≤ α, reject H₀. If p > α, fail to reject H₀.