Chi-Square Calculator — Goodness of Fit Test (Free)

StatisticsFreeNo sign-up

A chi-square calculator tests whether observed counts match expected counts. Add (O − E)²/E over every category, then compare the total with the chi-square distribution. For a die rolled 60 times showing 8, 9, 12, 11, 6 and 14, each expected count is 10, so χ² = 4.2 with 5 degrees of freedom and p = 0.521: no evidence the die is unfair.

Chi-square calculator
Separate values with commas or spaces. Expected values can be counts, proportions (0.25, 0.25, 0.5), percentages or a ratio such as 9 3 3 1.
Try:
Chi-square goodness-of-fit statistic
χ² = 4.2

χ²(5) = 4.2, p = 0.5210. p is greater than α = 0.05, so the data are consistent with H₀ (fail to reject).
Degrees of freedomdf = 6 − 1 = 5
p-value0.5210
Critical value (α = 0.05)11.070
Total N60
Effect sizew = 0.265 (small; cut-offs 0.1, 0.3, 0.5)
Smallest expected count10
Decision at α = 0.05
Fail to reject H₀ (not significant)
Observed vs expected
Category Observed O Expected E O − E (O − E)²/E Std. residual
Category 1 8 10 −2 0.4 −0.63
Category 2 9 10 −1 0.1 −0.32
Category 3 12 10 2 0.4 0.63
Category 4 11 10 1 0.1 0.32
Category 5 6 10 −4 1.6 −1.26
Category 6 14 10 4 1.6 1.26
Total 60 60 0 4.2
Standardized residual = (O − E)/√E. Values beyond ±2 (highlighted) show which categories drive the result.
Chi-square distribution, df = 5

Chi-square curve with 5 degrees of freedom. The shaded right tail beyond the statistic 4.2 is the p-value; the dashed line is the critical value 11.070 at alpha 0.05.05101520

p-value area beyond χ² = 4.2critical value 11.070 (α = 0.05)
Show steps
  1. Hypotheses. H₀: the population follows the expected distribution (all 6 categories equally likely). H₁: it does not.
  2. Expected counts: E = N / k = 60 / 6 = 10 for every category.
  3. For each category compute (O − E)²/E: (8 − 10)²/10 = 0.4; (9 − 10)²/10 = 0.1; (12 − 10)²/10 = 0.4; (11 − 10)²/10 = 0.1; (6 − 10)²/10 = 1.6; (14 − 10)²/10 = 1.6.
  4. Add them: χ² = Σ(O − E)²/E = 4.2.
  5. Degrees of freedom: df = k − 1 = 6 − 1 = 5. (If you estimated parameters from the data, such as a mean, subtract one more for each.)
  6. p-value = P(χ² > 4.2) for df = 5 = 0.5210. The critical value at α = 0.05 is 11.070.
  7. Fail to reject H₀: 4.2 ≤ 11.070 (p > α). The observed counts are consistent with the expected distribution.
  8. Effect size: w = √(χ²/N) = √(4.2/60) = 0.265, a small effect.
Critical values for df = 5
Significance level α Critical χ² χ² > critical?
0.1 9.236 No
0.05 11.070 No
0.025 12.833 No
0.01 15.086 No
0.005 16.750 No
0.001 20.515 No
Reject H₀ when the statistic is larger than the critical value (equivalently, when p ≤ α). Your α is highlighted.

Chi-Square Calculator — Goodness of Fit Test (Free)
Embed this calculator on your site

Free to use on class pages, blogs and course pages. Copy the code below and paste it into your page:

How to use the chi-square calculator

  1. Pick the test. Goodness of fit checks one categorical variable against expected counts or proportions. Independence checks whether two categorical variables in a contingency table are related. p-value turns a χ² statistic and its degrees of freedom into a p-value.
  2. Enter the observed counts. For goodness of fit, leave the expected box empty when every category should be equally likely, or type expected counts, proportions, percentages or a ratio such as 9:3:3:1 (as 9 3 3 1). For independence, type the table and use + Row and + Column to resize it up to 10 × 10.
  3. Choose the significance level α (0.05 is the usual choice) and read χ², df, the p-value and the decision. Open Show steps for the full working.

The result also shows expected counts, each cell’s contribution, residuals, the effect size (Cohen’s w or Cramér’s V), a warning when expected counts are too small, the chi-square curve with the p-value shaded, and a table of critical values for your df.

The chi-square statistic

χ² = Σ (O − E)² / E, where O is an observed count and E the expected count for the same category or cell. A large χ² means the observed counts are far from what H₀ predicts. Always use counts, not percentages, for O.

  • Goodness of fit: E = N × (expected proportion), and df = k − 1 for k categories.
  • Independence: E = (row total × column total) / N, and df = (rows − 1)(columns − 1).

The p-value is the area of the chi-square curve to the right of your statistic. The calculator finds it with the regularized incomplete gamma function, p = Q(df/2, χ²/2), which is accurate far into the tail, so very small p-values are shown in scientific notation instead of being rounded to 0.

Worked examples

Goodness of fit: is the die fair?

Rolls of 1 to 6: 8, 9, 12, 11, 6, 14 (N = 60). If the die is fair, E = 60 / 6 = 10 for each face. Contributions: 0.4, 0.1, 0.4, 0.1, 1.6, 1.6, so χ² = 4.2 with df = 5. The p-value is 0.521, far above 0.05, and the critical value 11.070 is far above 4.2. Fail to reject H₀.

Goodness of fit with a ratio: Mendel’s peas

Mendel counted 315, 108, 101 and 32 peas (N = 556) where theory predicts 9:3:3:1. The expected counts are 556 × 9/16 = 312.75, then 104.25, 104.25 and 34.75. The statistic is χ² = 0.470 with df = 3, p = 0.925: the data fit the 9:3:3:1 ratio very well.

Test of independence: a 2 × 3 table

Two groups of 50 people choose among options A, B and C: group 1 picks 25, 15, 10 and group 2 picks 15, 25, 10. The column totals are 40, 40 and 20, so the expected counts are 20, 20 and 10 in each row. χ² = 1.25 + 1.25 + 0 + 1.25 + 1.25 + 0 = 5.0 with df = (2 − 1)(3 − 1) = 2, p = 0.082. At α = 0.05 there is not enough evidence of an association; Cramér’s V = √(5 / (100 × 1)) = 0.224.

A 2 × 2 table with and without Yates’ correction

For the table 42, 18 / 28, 32 (N = 120), Pearson’s χ² = 6.72 with df = 1 and p = 0.0095. With Yates’ continuity correction, χ² = 5.794 and p = 0.016. Both are significant at 0.05; the correction always makes a 2 × 2 test a little more cautious.

Chi-square critical values table

Reject H₀ when your χ² is larger than the value in your df row and α column.

df α = 0.10 α = 0.05 α = 0.01 α = 0.001
1 2.706 3.841 6.635 10.828
2 4.605 5.991 9.210 13.816
3 6.251 7.815 11.345 16.266
4 7.779 9.488 13.277 18.467
5 9.236 11.070 15.086 20.515
6 10.645 12.592 16.812 22.458
7 12.017 14.067 18.475 24.322
8 13.362 15.507 20.090 26.124
9 14.684 16.919 21.666 27.877
10 15.987 18.307 23.209 29.588
12 18.549 21.026 26.217 32.909
15 22.307 24.996 30.578 37.697
20 28.412 31.410 37.566 45.315
25 34.382 37.652 44.314 52.620
30 40.256 43.773 50.892 59.703

Expected counts below 5 and effect size

The chi-square test is an approximation that works when expected counts are large enough. A common rule (Cochran’s) asks that no expected count is below 1 and no more than 20% are below 5. When the rule fails, combine small categories, collect more data, or for a 2 × 2 table use Fisher’s exact test. The calculator counts the low cells and shades them for you.

A p-value says whether a difference is likely to be real, not how big it is. With a large N even a tiny difference becomes significant, so report an effect size too. Cramér’s V = √(χ² / (N × min(r − 1, c − 1))) runs from 0 (no association) to 1. For a 2 × 2 table it equals |φ|, and 0.1, 0.3 and 0.5 are the usual cut-offs for small, medium and large. For goodness of fit, Cohen’s w = √(χ² / N) uses the same cut-offs.

Common mistakes

Mistake Fix
Entering percentages as observed values Use the actual counts; a chi-square test on percentages gives a wrong χ².
Wrong degrees of freedom k − 1 for goodness of fit, (r − 1)(c − 1) for independence, not N − 1.
Ignoring small expected counts Check the warning; combine categories or use an exact test.
Saying H₀ is proven A large p-value means “no evidence of a difference”, not proof that there is none.
Counting one person twice Each subject must fall in exactly one cell, and observations must be independent.

Checking homework with the calculator

Work out the expected counts and contributions by hand first. Then compare with the table in the result: if your χ² differs, the first cell that does not match shows where the slip happened. Most textbook answers round to 2 or 3 decimals, so tiny differences in the last digit are normal.

Chi-square test practice quiz: 10 questions

Test yourself with 10 multiple-choice questions. Choose an answer and press Submit to see if you are right and why. Your score appears at the end.

Question 1 of 10
1. A category has observed count 30 and expected count 25. What is its contribution to χ²?

Found a mistake? Let us know!

2. A goodness-of-fit test has 5 categories. How many degrees of freedom does it have?

Found a mistake? Let us know!

3. A contingency table has 3 rows and 4 columns. What are the degrees of freedom?

Found a mistake? Let us know!

4. In a table with N = 200, a cell’s row total is 80 and its column total is 50. What is its expected count?

Found a mistake? Let us know!

5. A coin is flipped 100 times and lands heads 60 times. What is χ² for a fair-coin test?

Found a mistake? Let us know!

6. For df = 1, what is the critical χ² value at α = 0.05?

Found a mistake? Let us know!

7. A test gives χ² = 9.2 with df = 2 at α = 0.05. What is the decision?

Found a mistake? Let us know!

8. A 2 × 2 table with N = 100 gives χ² = 9. What is Cramér’s V?

Found a mistake? Let us know!

9. Which situation breaks the usual expected-count rule for a chi-square test?

Found a mistake? Let us know!

10. Which data can a chi-square goodness-of-fit test use?

Found a mistake? Let us know!

Frequently asked questions

What does chi-square calculate?

It measures how far observed counts are from the counts you would expect under a hypothesis. The goodness-of-fit test compares one variable with a claimed distribution; the test of independence checks whether two categorical variables are related.

How do you calculate a p-value from chi-square?

Find the area to the right of the statistic under the chi-square curve with the right df. Use the p-value tab, a table (which only gives a range, such as 0.05 < p < 0.10), or a function such as CHISQ.DIST.RT in a spreadsheet. For χ² = 3.841 with df = 1, p = 0.05.

How do you do a chi-square goodness-of-fit test on a graphing calculator?

On a TI-84, put the observed counts in L1 and the expected counts in L2, then choose STAT, TESTS, χ²GOF-Test, enter df = k − 1 and calculate. The calculator here gives the same χ² and p-value and shows the working.

Is it chi-square or chi-squared?

Both are used. “Chi-square” is common in American textbooks and “chi-squared” in British and mathematical writing. The symbol is χ².

Is chi-square only for 2 × 2 tables?

No. The test of independence works for any r × c table (this calculator goes up to 10 × 10), and the goodness-of-fit test works for any number of categories. Only Yates’ correction is limited to 2 × 2 tables.

Related calculators

More statistics calculators

Browse all 206 calculators

Related to This Article

What people say about "Chi-Square Calculator: Goodness of Fit & Independence Test"?

No one replied yet.

Leave a Reply