Chi-Square Calculator

Use this free online chi-square calculator to run a goodness-of-fit test from observed and expected frequencies. Enter up to 4 categories to get the chi-square statistic, degrees of freedom, and p-value with a clear interpretation.

Enter Values

Actual count in category 1

Actual count in category 2

Actual count in category 3

Actual count in category 4

Expected count if null hypothesis is true

Expected count for category 2

Expected count for category 3

Expected count for category 4

Result

Enter values above and click Calculate to see your result.

AI Assistant

Ask about this calculator

I can help you understand the chi-square calculator formula, interpret your results, and answer follow-up questions.

Try asking

Formula

#
Core Formula
χ2=(OE)2E\chi^2 = \sum \frac{(O - E)^2}{E}

How it works: For each category, subtract the expected from the observed, square the difference, divide by expected. Sum across all categories. Larger values mean greater deviation from expected.

Review and Methodology

Updated Mar 26, 2026

This calculator runs locally in your browser. Inputs are converted into the units required by the formula, and the result is paired with supporting references so you can verify the method before using it for planning or estimates.

Worked Example

Observed: [20, 30, 25, 25], Expected: [25, 25, 25, 25]
1Step 1: Cat 1: (20-25) squared / 25 = 1.00
2Step 2: Cat 2: (30-25) squared / 25 = 1.00
3Step 3: Cat 3: (25-25) squared / 25 = 0.00
4Step 4: Cat 4: (25-25) squared / 25 = 0.00
5Step 5: Chi-square = 2.00, df = 3
6Step 6: p-value = approximately 0.572
Result: No significant deviation from expected distribution.

What Is the Chi-Square Goodness-of-Fit Test?

The chi-square goodness-of-fit test determines whether observed frequency data matches an expected distribution. It answers: "Do these observed counts differ from expected by more than random chance?"

  • Common uses: testing die fairness, survey distributions, genetic ratios
  • The test statistic is always non-negative because differences are squared
  • Degrees of freedom = number of categories minus 1 (df = k - 1)
  • Rule of thumb: all expected counts should be at least 5 for the approximation to be reliable
  • The chi-square test is one-tailed (right-tailed) because only large values indicate poor fit

The chi-square test is non-parametric and widely used in genetics, quality control, market research, and social sciences.

You can also calculate changes using our Degrees of Freedom Calculator, Test Statistic Calculator, F-Test Calculator or T-Test Calculator.

Frequently Asked Questions

What does the chi-square test check?

It checks whether observed frequencies differ from expected frequencies by more than random chance. A significant result means the observed distribution does not match the expected one.

Can expected counts be zero?

No. Expected values must be positive because the formula divides by E. The general rule is all expected counts should be at least 5.

What is the difference between goodness-of-fit and independence tests?

Goodness-of-fit tests one variable against an expected distribution. Independence tests whether two categorical variables are related using a contingency table.

How do I test whether a die is fair?

Roll the die many times and record counts for each face. Expected = total rolls / 6 for each face. If p-value is below alpha, the die is likely unfair.

What if expected counts are less than 5?

The chi-square approximation becomes unreliable. Options: combine categories, use Fisher's exact test for 2x2 tables, or use exact multinomial tests.

Can I use chi-square for continuous data?

Not directly. Chi-square requires categorical count data. For continuous data, consider the Kolmogorov-Smirnov or Shapiro-Wilk tests.

How can I put this Chi-Square Calculator on my blog or website?

Yes, the Chi-Square Calculator is fully embeddable. Tap "Embed" above to configure appearance and copy the code. It is free to use, works on any platform (HTML, WordPress, CMS), and adjusts to any screen size automatically. Visit calculory.com/services/embed-calculators for the complete guide.

Accurate and Reliable

All calculations run locally. Trusted statistical analysis with step-by-step breakdowns.

Verified Precision

Precise Statistical Calculations Powered by Calculory AI