Saved

Press the star next to a tool's name to save it.

All my tools

Chi Square Calculator

Use this chi square calculator to run a goodness of fit test or a test of independence from your counts and get the statistic, degrees of freedom, p-value and expected counts.

Restored your last values ·

For a goodness of fit test, enter the observed counts, and the expected counts or proportions, or leave them empty to test equal shares. For a test of independence, enter a table with one row on each line. You get the chi-square statistic, the degrees of freedom and the p-value.

Everything is worked out in your browser. Nothing you type is sent anywhere.

–

–

Choose the test, enter your counts, then press Calculate.

A chi square calculator tests whether counts in categories fit what you expected, or whether two categorical variables are linked. Enter the observed counts, and the expected counts or proportions, for a goodness of fit test. Or enter a table of counts for a test of independence. You get the chi-square statistic, the degrees of freedom, the p-value and the expected counts in each cell. It runs in your browser.

How to use the chi square calculator

  1. Choose goodness of fit or independence.
  2. Enter the observed counts, and the expected values, or a table, with one row per line.
  3. Press Calculate.

Goodness of fit

The Wikipedia article on the chi-squared test gives the statistic for a goodness of fit test as X² = Σ (xᵢ − mᵢ)² ÷ mᵢ, where xᵢ is the observed count of category i and mᵢ = n × pᵢ is the count expected from the hypothesis. It says that the statistic follows a chi-squared distribution with k − 1 degrees of freedom, where k is the number of categories.[1] Take a die that is rolled 60 times with the counts 5, 8, 9, 8, 10 and 20 for the faces 1 to 6. If the die is fair, the expected count of each face is 10. The statistic is (25 + 4 + 1 + 4 + 0 + 100) ÷ 10 = 13.4, with 5 degrees of freedom, and the p-value is about 0.02, so the die looks unfair. This die example is our own, as the page has no numeric one for goodness of fit. Enter the six counts and leave the expected box empty to check.

Test of independence

For a table of counts, the expected count in each cell is the row total times the column total divided by the grand total. The page does not state this as a general formula, but its example uses it: the expected count is 150 × 349 ÷ 650, which is about 80.54.[1] The degrees of freedom are the number of rows minus one times the number of columns minus one.[1] The calculator shows the expected counts of all the cells so that you can check them.

A worked example from the page

The page's example is a table of 650 people, classed by job and by neighbourhood. The white collar row is 90, 60, 104 and 95, which total 349, the blue collar row is 30, 50, 51 and 20, which total 151, and the no collar row is 30, 40, 45 and 35, which total 150. The column totals are 150, 150, 200 and 150. The cell for white collar in the first neighbourhood has an expected count of 80.54 and contributes about 1.11 to the statistic. The sum is about 24.57, with (3 − 1)(4 − 1) = 6 degrees of freedom.[1] The page stops at saying that an improbably large statistic leads you to reject independence. The calculator gives the p-value, about 0.0004, which is far below 0.05, so the job and the neighbourhood are linked in this table.

Assumptions

The article says that the test assumes that the observations are independent, and that each one falls into exactly one category. It also says that the expected counts are often recommended to be at least 5, and that exact tests or other methods are preferred when they are smaller.[1] The calculator warns you when any expected count is below 5. Do not use the test on percentages or on anything but counts, and do not count the same person twice.

Yates' continuity correction

For a 2 × 2 table, Yates suggested a correction for continuity, in which 0.5 is subtracted from the absolute difference between each observed and expected count. The page says that this reduces the chi-squared value and so raises its p-value.[1] The calculator has an option for it. For the table 10, 20, 30 and 40, the correction lowers the statistic a little. It is a conservative choice and is mostly used for small tables.

A small p-value says that a link is unlikely to be due to chance, but not how strong it is, since a large table gives a tiny p-value even for a weak link. As a measure of strength, the calculator also shows Cramér's V, the square root of the statistic divided by N times the smaller of rows − 1 and columns − 1, which is our own addition. It runs from 0 for no link to 1 for a perfect link.

Reading the result

If the p-value is below your significance level, usually 0.05, reject the null hypothesis: the counts do not fit the expected shares, or the variables are not independent. Look at the contributions of each category, which the calculator lists, to see where the difference is. A large contribution marks a category with a count far from what was expected.

Entering your table

Type one row of the table on each line, with the counts separated by spaces or commas, and the same number of counts on every line. The categories can be in any order. Do not include the totals, as the calculator works them out. Rows or columns that are all zero are refused, since they cannot give an expected count.

Common mistakes

  • Using percentages. The test needs counts.
  • Small expected counts. Below 5, use an exact test.
  • Dependent observations. The same person counted twice breaks the test.
  • Reading the p-value as the size of an effect. It is not.

What next

Use this often? Add Chi Square to your Home screen.

Frequently asked questions

What is a chi square calculator?

A tool that runs a chi-square test on counts, either to see if they fit expected shares or to see if two categorical variables are independent.

What is the chi-square formula?

X² = Σ (observed − expected)² ÷ expected, with the expected count from the hypothesis.

How are the degrees of freedom found?

For goodness of fit, k − 1 for k categories. For independence, (rows − 1) × (columns − 1).

What is an expected count in a table?

The row total times the column total divided by the grand total. For 150 × 349 ÷ 650 it is about 80.54.

When should I not use the chi-square test?

When expected counts are very small, usually below 5, or when the observations are not independent.

What went wrong?

We only receive the reason you pick, never what you typed into the tool.

Thanks for your feedback.

More Math Tools