Chi-Square Goodness of Fit Calculator

StatisticsLast updated: August 22, 2026

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.

Enter the number of observations in each category, separated by commas, spaces, or line breaks. At least 2 categories are required, and the values must be non-negative counts.
Separate them with commas. If you leave this empty, "Category 1, Category 2, …" is used.
You can enter ratios (1, 1, 2), percentages (25, 25, 50), or expected frequencies directly; the total is rescaled proportionally to the observed total. Separate decimal values with spaces or line breaks.
Sets the false-positive risk. In the social sciences 5% is the usual choice.

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

  1. Enter the number of observations (the frequencies) falling into each category; enter counts, not percentages.
  2. If you like, add the category names separated by commas; the table and charts are labeled with them.
  3. 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.
  4. Choose the significance level and read χ², df, p, and the critical value: if χ² exceeds the critical value, the fit is rejected.
  5. Look at Cohen's w to judge the practical size of the departure; the p-value alone is not enough.
  6. 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

Frequently Asked Questions

What is the difference between the goodness-of-fit test and the test of independence?
The goodness-of-fit test compares the observed distribution of a single categorical variable with a theoretical distribution, and its degrees of freedom are k − 1. The test of independence asks whether two categorical variables measured on the same sample are associated, using a contingency table, and its degrees of freedom are (r−1)(c−1). The formula looks the same, but the questions are entirely different.
How should I enter the expected proportions?
All three forms are accepted: ratios (1, 1, 2), percentages (25, 25, 50), or expected frequencies directly (30, 30, 60). If the entered values do not sum to the observed total, the calculator rescales them proportionally and tells you so. Leave the field empty and all categories are treated as equally likely.
What happens if an expected frequency falls below 5?
The χ² distribution is an approximation, and it breaks down when expected frequencies are small. The traditional rule is that every expected frequency should be above 1 and no more than 20% of them should fall below 5. If that fails, merge similar categories, collect more data, or use an exact multinomial test or a Monte Carlo simulation.
How do I find out which category is causing the misfit?
Look at the adjusted residual column. That value is approximately standard normal, so categories whose absolute value exceeds 1.96 differ from expectation at the 5% level; a positive value means more observations than expected, a negative one fewer. The χ² contribution column shows which category is inflating the test statistic.
How do I interpret Cohen's w?
It is computed as w = √(χ²/n) and measures the departure with the sample size divided out. Cohen's cutoffs are 0.10 small, 0.30 moderate, and 0.50 large. Since in large samples the p-value comes out significant almost every time, w is what tells you whether the departure actually matters; it is also the value used in power analysis.
How do I get the same result in SPSS, R, and Excel?
In SPSS, Analyze > Nonparametric Tests > Legacy Dialogs > Chi-Square gives the same χ² and p-value. In R, use chisq.test(c(18, 22, 16, 24, 20, 20)), or chisq.test(x, p = c(...)) for unequal expected proportions. In Excel, CHISQ.TEST returns the p-value directly and CHISQ.INV.RT returns the critical value.
Can I use this test to check whether a continuous variable is normally distributed?
Technically you can bin the data and apply it, but it is not recommended: the result depends on how many bins you choose, and you have to lower the degrees of freedom by hand for every estimated parameter. For normality, the Shapiro-Wilk, Anderson-Darling, and Kolmogorov-Smirnov tests are far more powerful.