Calculateus

Chi-Square Goodness of Fit Calculator

Calculate the chi-square statistic to test how well observed data fits expected frequencies.

Result

Chi-Square Statistic
2.9
Degrees of Freedom
4

Compare this statistic to a chi-square critical value table at your chosen significance level and degrees of freedom to determine statistical significance.

About the Chi-Square Calculator

The Chi-Square Goodness of Fit Calculator checks how closely a set of observed category counts matches the counts you'd expect under a hypothesis. It's built for situations where you've tallied outcomes into categories, such as die faces, survey responses, or defect types, and want to know whether the deviations from an expected pattern are large enough to matter. The result is a single chi-square statistic plus its degrees of freedom, ready to compare against a critical value table.

How It Works

Enter your observed frequencies and your expected frequencies as two comma-separated lists, keeping the categories in the same order in both. For each category, the calculator subtracts the expected count from the observed count, squares that difference, and divides by the expected count; it then adds those per-category values together to get the chi-square statistic. Degrees of freedom is reported automatically as one less than the number of categories you entered.

Chi-square = sum over all categories of (Observed - Expected)^2 / Expected; degrees of freedom = number of categories - 1.

Formula & Methodology

By hand, list each category's observed and expected count side by side. For every category, subtract expected from observed, square the result, and divide by that category's expected count. Add all of those quotients together for the chi-square statistic, and count your categories to get degrees of freedom (categories minus one).

Examples

A five-category survey against a uniform expectation

With observed counts of 18, 22, 20, 25, and 15 tested against an expected count of 20 in each of five categories, the calculator sums (18-20)^2/20, (22-20)^2/20, (20-20)^2/20, (25-20)^2/20, and (15-20)^2/20 to get a chi-square statistic of 2.9 with 4 degrees of freedom.

Checking candy color counts against an equal split

A bag of 100 candies with 24, 18, 22, 19, and 17 pieces across five colors, tested against an expected 20 per color, produces a chi-square statistic of 1.7 with 4 degrees of freedom - a small deviation consistent with an even color mix.

Advantages

  • Turns a table of raw counts into a single comparable number, instead of eyeballing which categories look 'off'.
  • Automatically computes degrees of freedom, a step that's easy to get wrong when done by hand.
  • Works with any number of categories, so it scales from a simple two-outcome test up to distributions with many groups.

Common Mistakes

  • Entering percentages or proportions instead of raw counts, which distorts the statistic since it's not scale-invariant.
  • Using expected values that don't sum to the same total as the observed values, which usually signals a setup error in the hypothesis being tested.
  • Applying the test when several expected counts are very small (a common rule of thumb is under 5), where the chi-square approximation becomes unreliable.

Edge Cases to Watch For

  • Observed and expected lists must contain the same number of values; a mismatch returns an error instead of a partial result.
  • Every expected frequency must be strictly positive, since dividing by an expected value of zero would make the statistic undefined for that category.
  • The calculator reports the statistic and degrees of freedom only; it does not compute a p-value, so you still need to check the result against a chi-square critical value table at whatever significance level you're using.

Common Use Cases

  • Quality control teams checking whether defect counts across production categories match a historical baseline.
  • Biology and genetics students testing observed trait ratios against Mendelian expected ratios.
  • Market researchers checking whether survey response categories match an assumed or historical distribution.
Written & fact-checked by the Calculateus TeamLast updated August 5, 2026How we verify our formulas

Frequently asked questions

What does the chi-square statistic measure?

It measures the total squared discrepancy between what you observed and what you'd expect under a hypothesis, scaled by the expected value - a larger chi-square statistic means the observed data deviates more from the expected pattern, and is compared against a critical value to determine if the difference is statistically significant.

Conclusion

The chi-square goodness of fit statistic gives a standardized way to measure how far observed category counts stray from an expected pattern. Pair the statistic and degrees of freedom this calculator produces with a chi-square critical value table to judge whether the deviation is likely more than chance.