Chi-square tests – goodness of fit, independence and homogeneity

MathematicsStatisticsAges 17–18

Loading…

Use with my class ✨ Customize with AI Report a problem

Roll a fair or loaded die, open bags of coloured sweets or type your own counts, and test them against stated proportions; or edit a two-way table to test independence or homogeneity. Expected counts, every (O − E)²/E contribution, χ², the degrees of freedom and the chi-square curve with the p-value shaded and the critical value marked lead to a decision, with a warning when an expected count is below 5.

Lesson: Chi-square tests: goodness of fit, independence and homogeneity

What it shows

A chi-square test compares observed counts O with the counts E expected if the null hypothesis were true. Each category or cell adds (O − E)²/E to the statistic χ². When H₀ is true and every expected count is at least 5, χ² approximately follows a chi-square distribution with k − 1 degrees of freedom for goodness of fit, or (r − 1)(c − 1) for a two-way table. The p-value is the area to the right of χ²; the sim computes it exactly with the regularised incomplete gamma function. Simulated dice and sweets show how often a true H₀ is still rejected.

How to use

On the Goodness of fit screen, choose the Data, then Roll once, Roll 60 times or open bags of sweets, or type counts in the table; switch the Die used to Loaded and watch χ² grow. On the Two-way table screen, pick an Example, edit any count, add or remove rows and columns, and choose Independence or Homogeneity. Change the Significance level α and compare the p-value with the critical value.

Parameters you can change

  • Screen Goodness of fit, Two-way table
  • Goodness-of-fit data Rolling a die, Colours of sweets, Your own proportions
  • Simulated die or bag Matches H₀ (fair die, stated mix), Differs from H₀ (loaded die, different mix)
  • Rolls or sweets per batch 10–500
  • Number of categories k (own proportions) 2–8
  • Two-way table test Independence, Homogeneity
  • Two-way table example Age group × transport to school, Fertiliser × germination, Blank 2 × 2 table
  • Significance level α 0.10, 0.05, 0.01
  • Random seed (same seed, same data) 1–999

Questions to explore

  1. How many rolls of a loaded die do you need before the test usually rejects H₀?
  2. Why does a table with 3 rows and 4 columns have 6 degrees of freedom?
  3. Which cell contributes most to χ², and what does it say about the association?