Chi-Squared Goodness-of-Fit Calculator
Enter observed and expected counts to compute the chi-square statistic, degrees of freedom, p-value, and decision at your chosen significance level.
What is a chi-squared goodness-of-fit test?
A chi-squared goodness-of-fit test checks whether your observed category counts match a hypothesized distribution. In plain language: it asks, “Are these differences from expected values just random noise, or are they too large to ignore?”
This is useful when your data are counts in categories (for example: survey responses, dice outcomes, genetic ratios, defect types, or customer choices).
Formula used by this calculator
The test statistic is:
χ2 = Σ (Oi − Ei)2 / Ei
- Oi = observed count in category i
- Ei = expected count in category i
- df = k − 1 − m, where k is number of categories and m is number of estimated parameters
The p-value is computed from the chi-square distribution with the calculated degrees of freedom.
How to use this calculator
Step 1: Enter observed counts
Paste your observed counts into the first box. Example: 18, 22, 25, 15, 20.
Step 2: Enter expected counts
Enter expected counts for each category in the same order and with the same number of values.
Example for equal expected outcomes: 20, 20, 20, 20, 20.
Step 3: Set α and estimated parameters
Choose your significance level (commonly 0.05). If your expected values were estimated from the same data (for example, fitting distribution parameters), enter how many parameters you estimated.
Step 4: Interpret the result
- If p < α: reject the null hypothesis (data do not fit expected distribution well).
- If p ≥ α: fail to reject the null hypothesis (data are reasonably consistent with expected distribution).
Practical example
Suppose you roll a die 120 times. If the die is fair, each face should appear about 20 times. You observe: 14, 22, 18, 25, 16, 25. Enter those as observed and expected as 20,20,20,20,20,20. The calculator will return the chi-square statistic and p-value so you can assess fairness statistically.
Assumptions and common mistakes
- Use count data, not percentages directly.
- Expected counts should generally be large enough (rule of thumb: most are at least 5, none below 1).
- Categories should be mutually exclusive and collectively exhaustive.
- Observations should be independent.
- Observed and expected arrays must have the same number of categories.
Quick FAQ
Can I use probabilities instead of expected counts?
Convert probabilities to expected counts first by multiplying each probability by your total sample size.
What if totals for observed and expected differ?
For a standard goodness-of-fit setup, totals should match. If they differ, double-check your expected counts.
Is this the same as chi-square test of independence?
No. Goodness-of-fit compares one categorical variable to a theoretical distribution. Independence compares two categorical variables in a contingency table.