Chi-Squared Test
Visualize the Chi-Squared goodness-of-fit test by comparing observed and expected frequencies.
Free theory articleVisualize the Chi-Squared goodness-of-fit test by comparing observed and expected frequencies.
Concept & interpretation
A goodness-of-fit test compares category counts with the counts predicted by a specified probability model. This explorer uses equal probabilities, so every expected count is the total divided by the number of categories. Taller gaps matter more because the Pearson statistic squares each gap before dividing by its expected count.
Keep the evidence fixed, change the rule
Open the Chi-Squared Test explorer and use its four sliders:
- Set Number of Categories (k) to 3, Sample Size (n) to 30, Distribution Skew to −3 and Significance Level (α) to 0.05. Check expected count 10.00, statistic 4.200, two degrees of freedom and p-value 0.1225. Hover the bars to inspect their counts.
- Change only Significance Level (α) to 0.20. The critical value falls and the conclusion changes to Reject H0. Bar heights, statistic and p-value stay fixed; the third observed bar changes color because the display threshold also depends on α.
- Return α to 0.05, then set Distribution Skew to 0. The generated counts become 10, 10 and 10: the statistic is 0.000 and the reference p-value is 1.0000. Perfect agreement in these observed counts does not prove that population probabilities are equal.
- For a second check, use the default values k = 4, n = 100, skew = 0 and α = 0.05. Counts 28, 22, 22 and 28 each differ from their expectation 25 by three in magnitude. Four contributions of 9 / 25 sum to 1.440, with three degrees of freedom and displayed p-value 0.6962.
The legend occupies its own space above the plot. Gray bars show expectations; indigo and red bars show generated observations. Red means a contribution exceeds the displayed critical value divided by k. It is a visual heuristic, not a separate hypothesis test for that category. On a narrow screen, scroll the controls panel to reach the statistics.