Statisticschi-squaregoodness of fithypothesis test

Chi-Square Test Calculator

Compute the chi-square (χ²) test statistic by comparing observed and expected frequencies. Used to test whether data fits a theoretical distribution or whether two categorical variables are independent.

Advertisement

Calculator

See your Chi-Square Test Calculator results

Enter your email to unlock results — free forever.

or

No spam, ever. Unsubscribe at any time.

Advertisement

Formula

χ² = Σ (Observed − Expected)² / Expected

For each category, subtract the expected frequency from the observed frequency, square the result, and divide by the expected frequency. Sum these values across all categories to get the chi-square statistic. Larger values indicate greater discrepancy between observed and expected counts. The resulting statistic is compared to a critical value from the chi-square distribution to determine statistical significance.

How to use the Chi-Square Test Calculator

  1. 1

    Enter your observed count 1

  2. 2

    Enter your expected count 1

  3. 3

    Enter your observed count 2

  4. 4

    Enter your expected count 2

  5. 5

    Read your results instantly

    Results update in real time as you type.

Advertisement

What the chi-square test evaluates

The chi-square goodness-of-fit test asks: could the observed data plausibly have come from a distribution with the specified expected frequencies? For example, if you flip a coin 100 times and get 60 heads and 40 tails, the expected counts are 50 each. The chi-square statistic measures how surprised you should be by this outcome if the coin is fair.

For two categories with 1 degree of freedom, the critical value at p=0.05 is 3.841. A chi-square statistic above 3.841 would lead you to reject the null hypothesis (that the coin is fair) at the 5% significance level.

Degrees of freedom and critical values

Degrees of freedom (df) equal the number of categories minus 1 for a goodness-of-fit test. With two categories, df=1. With four categories, df=3. The critical chi-square value increases with df.

Common critical values at p=0.05: df=1 → 3.841, df=2 → 5.991, df=3 → 7.815, df=4 → 9.488. If your calculated χ² exceeds the critical value for your df, the result is statistically significant at the 5% level. Look up exact p-values in a chi-square table or statistical software.

Advertisement

Sample size requirements

The chi-square test requires adequate sample sizes to be valid. The standard rule of thumb is that all expected cell counts should be at least 5. If any expected count is below 5, the chi-square approximation may be poor and Fisher's exact test is preferred.

For a two-by-two contingency table with small counts, always use Fisher's exact test. The chi-square approximation becomes increasingly accurate as expected cell counts grow — it is excellent when all expected counts exceed 20.

Tips & Insights

Expected counts, not proportions

Enter actual counts (number of observations), not proportions or percentages. Both observed and expected values must be on the same scale, and expected values should reflect the total sample size.

Chi-square is always positive

Because each term is a squared quantity divided by a positive number, χ² is always ≥ 0. A value of 0 means observed perfectly matches expected.

Add more categories for more precise tests

With more categories (higher df), the test is more sensitive to detecting specific types of departures from the expected distribution. Two categories only detect overall imbalance.

Worked Examples

Coin fairness test

Observed heads: 60Expected heads: 50Observed tails: 40Expected tails: 50

χ² = 4.0. With df=1, the critical value at p=0.05 is 3.841. χ² > 3.841, so we reject the null hypothesis that the coin is fair at the 5% level.

Mendelian genetics ratio

Observed dominant: 315Expected dominant: 300Observed recessive: 85Expected recessive: 100

χ² ≈ 3.0. Below the critical value of 3.841, so the observed ratio is consistent with the expected 3:1 Mendelian ratio at the 5% level.

Advertisement

Frequently Asked Questions

What does the chi-square test measure?

The chi-square test measures how much observed frequencies differ from expected frequencies. A large chi-square statistic suggests the observed data is unlikely if the null hypothesis (expected distribution) is true.

What is a chi-square critical value?

The critical value is the threshold chi-square statistic above which you reject the null hypothesis. It depends on the degrees of freedom and significance level. At p=0.05 with 1 df, the critical value is 3.841.

What are degrees of freedom in a chi-square test?

For a goodness-of-fit test, df = number of categories − 1. For a contingency table, df = (rows − 1) × (columns − 1).

When should I use Fisher's exact test instead?

Use Fisher's exact test when any expected cell count is below 5, when sample sizes are small, or when you have a 2×2 table with sparse data. Fisher's test is exact rather than approximate.

Can I use chi-square with continuous data?

Chi-square requires categorical (count) data. For continuous data, use different tests (t-test, ANOVA, Kolmogorov-Smirnov). However, you can bin continuous data into categories and apply chi-square to the bins.

Advertisement

Related Calculators