Percentages and Math

Chi Square Calculator

Test whether two categories are related, or whether counts fit the pattern you expected.

Your numbers

Test

Separate the columns with commas or spaces and put each row on its own line. Whole numbers, at least 2 rows and 2 columns.

Result

Chi-square

0.7937

1 degree of freedom, p-value 0.373

Chi-square statistic
0.7937
Degrees of freedom
1
p-value
0.373
Total count
100
Cramér's V (effect size)
0.0891
Smallest expected count
12

Observed counts

Col 1Col 2Total
Row 1102030
Row 2304070
Total4060100

Expected counts

Col 1Col 2
Row 11218
Row 22842

Contribution of each cell to chi-square

Col 1Col 2
Row 10.33330.2222
Row 20.14290.0952
How this was calculated
  1. For each cell, expected count = row total x column total / grand total (100).
  2. Each cell adds (observed - expected)^2 / expected. The chi-square statistic is the sum over all cells.
  3. Degrees of freedom = (rows - 1) x (columns - 1) = 1. Chi-square = 0.7937.
  4. p-value = the upper tail of the chi-square distribution with 1 degrees of freedom at 0.7937, computed from the regularized incomplete gamma function: 0.373 (exact value 0.372998).
  • The p-value is the probability, if the two variables were independent, of a chi-square statistic at least this large. It does not measure how strong the relationship is (see Cramér's V) and it does not show cause. Use counts, not percentages.

Calculated using SumPanda.com · https://sumpanda.com/chi-square-calculator/

Results are estimates for general information. Verify important figures before relying on them.

Next step

How to use the chi square calculator

  1. Choose Independence to test whether two categories are related using a table of counts, or Goodness of fit to test whether counts match the pattern you expected.
  2. For independence, type the observed counts with one row per line and the columns separated by commas or spaces. Use counts, not percentages.
  3. For goodness of fit, enter the observed counts for each category, then choose equal expected counts, percentages that add up to 100, or expected counts that add up to the observed total.
  4. Read the chi-square statistic, the degrees of freedom and the p-value, and check the warning about small expected counts.

Formula

Expected count (independence) = row total x column total / grand total

Chi-square = sum of (observed - expected)^2 / expected

Degrees of freedom = (rows - 1) x (columns - 1), or categories - 1 for fit

p-value = P(chi-square >= observed statistic) = Q(df/2, x/2)

Q is the regularized upper incomplete gamma function. For a 2 by 2 table the optional Yates correction replaces each |O - E| with |O - E| - 0.5 (not below zero).

A 2 by 2 table

A table has counts 10 and 20 in the first row and 30 and 40 in the second. The row totals are 30 and 70, the column totals are 40 and 60, and the grand total is 100. The expected counts are 12, 18, 28 and 42. The statistic is 4/12 + 4/18 + 4/28 + 4/42 = 0.7937 with 1 degree of freedom, which gives a p-value of 0.3730. With the Yates correction it is 0.4464 and the p-value is 0.5040.

For goodness of fit, take observed counts of 18, 22, 30 and 30 and equal expected counts of 25 each. The statistic is (49 + 9 + 25 + 25) / 25 = 4.32 with 3 degrees of freedom and a p-value of 0.2289.

Reading the p-value

The p-value is the probability of getting a chi-square statistic at least this large if the null hypothesis were true: the two categories are unrelated, or the counts follow the expected pattern. A small p-value says the data would be surprising under that assumption. A large one says only that the data do not contradict it.

Where to draw the line is your choice, set before looking at the data. This tool does not label results as significant, because that depends on your field and on how many tests you run. The p-value says nothing about how large the effect is, so the independence test also shows Cramér's V as a measure of strength from 0 to 1.

When the test is reliable

The chi-square test uses an approximation that works best when expected counts are not small. A widely used rule of thumb asks for expected counts of at least 5 in nearly all cells, and the tool warns when any cell falls below that. In that case consider combining categories or using an exact test.

The observations must be independent counts of individual cases, not percentages and not repeated measurements of the same people. To work with the probabilities behind the test, see the probability calculator and the binomial probability calculator.

Assumptions and limits

  • Counts are whole numbers of 0 or more, and each case is counted once.
  • Every row and column has at least one observation, otherwise an expected count would be zero and the test cannot be run.
  • The p-value is computed from the regularized incomplete gamma function and agrees with closed forms for whole degrees of freedom.
  • For goodness of fit, the degrees of freedom are categories minus 1, which assumes the expected counts were not estimated from the same data.

Formulas reviewed October 10, 2026. See the calculation methodology for how SumPanda rounds, tests and sources its formulas.

Frequently asked questions

What does a chi-square test of independence tell me?

It checks whether the counts in a table are consistent with two categories being unrelated. It compares each observed count with the count you would expect if they were unrelated and combines the differences into one statistic.

What is the difference between independence and goodness of fit?

Independence uses a table with two categorical variables and asks whether they are related. Goodness of fit uses one variable and asks whether its counts match a pattern you expected, such as equal shares.

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

For a table it is the number of rows minus 1 times the number of columns minus 1. For goodness of fit it is the number of categories minus 1. It sets which chi-square curve the p-value comes from.

When should I use the Yates correction?

It is an optional adjustment for 2 by 2 tables that makes the statistic a little smaller. Some courses require it and some consider it too conservative, so follow your course or your field's convention.

Why does the tool warn about expected counts below 5?

The chi-square distribution is only an approximation for the test statistic, and the approximation gets worse when expected counts are small. The warning is a prompt to combine categories or use an exact test.