Chi-Square Goodness of Fit Calculator
The chi-square goodness-of-fit test asks whether the observed distribution of a single categorical variable matches a theoretical expected distribution. "Is this die fair?", "Are births spread evenly across the days of the week?", "Does the regional composition of our sample match the population?" — these are all questions this test answers.
Give the calculator your observed frequencies, and optionally the expected proportions, and it returns the χ² statistic, the degrees of freedom, the p-value, the critical value for your chosen α, and Cohen's w effect size. It also produces the standardized and adjusted residuals that show which category is driving the misfit, checks the expected frequency assumption, and plots the observed against the expected counts.
Chi-Square Goodness of Fit Formulas
Expected (equal): Eᵢ = n / k Expected (weighted): Eᵢ = n · pᵢ, Σpᵢ = 1 Test statistic: χ² = Σᵢ (Oᵢ − Eᵢ)² / Eᵢ Degrees of freedom: df = k − 1 p-value: p = P(χ²₍df₎ ≥ χ²observed) Critical value: χ²₍1−α, df₎ Standardized residual: rᵢ = (Oᵢ − Eᵢ) / √Eᵢ Adjusted residual: zᵢ = (Oᵢ − Eᵢ) / √[Eᵢ(1 − Eᵢ/n)] Effect size: w = √(χ² / n)
When the expected values are entered as ratios or percentages they are rescaled proportionally to the observed total, so "1, 1, 2" and "25, 25, 50" give the same result. Only the adjusted residual is approximately standard normal and can therefore be read against the ±1.96 threshold.
How to Calculate
- Enter the number of observations (the frequencies) falling into each category; enter counts, not percentages.
- If you like, add the category names separated by commas; the table and charts are labeled with them.
- If your expected distribution is not uniform, enter the ratios (1, 1, 2) or the percentages (25, 25, 50) in the second box; leave it empty to assume an equal distribution.
- Choose the significance level and read χ², df, p, and the critical value: if χ² exceeds the critical value, the fit is rejected.
- Look at Cohen's w to judge the practical size of the departure; the p-value alone is not enough.
- Flag the categories whose adjusted residual goes beyond ±1.96: those are the sources of the misfit.
Worked Examples
Testing whether a die is fair
Across 120 rolls, the expected frequency for each of the six faces is 20.000. With χ²(5) = 2.0000, p = 0.849, and a critical value of 11.0705, the hypothesis that the die is fair cannot be rejected. Cohen's w = 0.1291 makes the departure small, and no category has an adjusted residual beyond the ±1.96 boundary.
Chi-square statistic (χ²): 2.0000 · Degrees of freedom (df): 5 · p-value (right tail): p = 0.849
Unequal expected proportions
A sample of 120 people is compared with last year's 50%-30%-20% distribution. The expected frequencies are rescaled to 60.000, 36.000, and 24.000; with χ²(2) = 0.3583 and p = 0.836 there is no evidence that the distribution has changed. Cohen's w = 0.0546 makes the effect negligible.
Chi-square statistic (χ²): 0.3583 · Degrees of freedom (df): 2 · p-value (right tail): p = 0.836
Violating the expected frequency assumption
With 18 observations spread over 5 categories the expected frequency is 3.600, and because it stays below 5 in all five categories the calculator raises an assumption warning. χ²(4) = 9.7778 and p = 0.044 make the result significant at α = 0.05, but since χ² sits very close to the critical value (9.4877) this p-value is only approximate and an exact multinomial test is preferable.
Chi-square statistic (χ²): 9.7778 · Degrees of freedom (df): 4 · p-value (right tail): p = 0.044