Chi Square Calculator

Disclaimer: This calculator gives estimates for general information only. It is not financial, medical or other professional advice. Chi-square tests work on counts, not percentages or measurements, and a small p-value is evidence against the null hypothesis under the test’s assumptions, not the probability that the null hypothesis is true.

What this calculator does

Chi-square is the standard test for counts. It answers questions like: do these category counts look like the pattern we expected, and are two ways of classifying the same items actually related? This page covers the three jobs chi-square is used for. The goodness-of-fit test compares one set of observed counts with an expected pattern, which can be equal shares, proportions you give, or expected counts you give. The test of independence works on a two-way table of counts and checks whether the row classification and the column classification move together. The distribution lookup goes the other way: given a chi-square statistic and its degrees of freedom it finds the p-value, and given degrees of freedom and a significance level it finds the critical value you would read from a printed chi-square table.

For the two tests, the page shows the statistic, the degrees of freedom, the p-value and a verdict at the significance level you set. Goodness of fit shows every category’s observed count, expected count and contribution to the statistic, so you can see which categories drive the result. Independence shows the expected count for every cell, which is also the honest way to check the test’s main assumption. Effect size for the independence test is Cramér’s V.

How to use it

  • Start from counts, always. Chi-square is built for whole-number counts of things. If your data are percentages, convert them back to counts out of their real totals first; running the test on percentages gives a statistic with no meaning, because the same percentages from 40 cases and from 40,000 cases carry completely different amounts of evidence.
  • Goodness of fit: type the observed counts in category order, then choose the comparison: equally likely categories, your own expected proportions (which must add up to 1), or your own expected counts.
  • Independence: set the table size, then type the observed count in each cell. Rows are one classification, columns the other; swapping rows and columns does not change the result.
  • Distribution lookup: choose whether you have a statistic (you get its upper-tail p-value and the lower tail as well) or just degrees of freedom (you get the critical value at the significance level set at the top of the card).
  • Read the expected counts, not just the p-value. Both tests assume the expected counts are not tiny. The result flags the smallest expected count so you can judge that for yourself.

How chi-square is calculated

The statistic

For every category or cell, take the observed count O and the expected count E under the null hypothesis, and add up (O minus E) squared, divided by E, over all of them. That sum is the chi-square statistic. If the null hypothesis is right, observed counts wander around the expected ones and the statistic stays small. The more the counts pull away from expectation, relative to how big the expectations are, the larger the statistic grows, and the smaller the p-value becomes. Chi-square only ever looks in one direction: big values argue against the null, small values never argue for anything except consistency with it.

Goodness of fit

The null hypothesis is that the counts follow the expected pattern. With equally likely categories, each expected count is the total divided by the number of categories. With proportions, each expected count is the total multiplied by that category’s proportion. With expected counts given directly, they are used as they stand. Degrees of freedom are the number of categories minus 1.

Test of independence

The null hypothesis is that the row and column classifications are independent. Under independence, the expected count in a cell is its row total multiplied by its column total, divided by the grand total. Degrees of freedom are (rows minus 1) multiplied by (columns minus 1). Cramér’s V puts the association on a 0 to 1 scale: it is the square root of the statistic divided by the total count and by the smaller of (rows minus 1) and (columns minus 1).

Degrees of freedom, p-values and critical values

The chi-square distribution is a family of curves, one for each degrees-of-freedom value, and the degrees of freedom say which curve your statistic is judged against. The p-value is the area under that curve to the right of your statistic: the probability of a statistic at least that large if the null hypothesis were true. A critical value turns the same idea around: it is the statistic value that leaves exactly the significance level (for example 0.05) in the right tail, so any statistic beyond it is significant at that level. That is all a printed chi-square table is: a grid of critical values by degrees of freedom and tail area, and the lookup mode on this page reproduces it for any degrees of freedom from 1 to 1,000.

Worked examples

Goodness of fit, a die rolled 96 times. The faces come up 12, 18, 15, 17, 16, 18. If the die is fair, each face is expected 96 / 6 = 16 times. The contributions are 1.00, 0.25, 0.06, 0.06, 0.00 and 0.25, adding to a statistic of 1.63 on 5 degrees of freedom, p = 0.8982. Nowhere near significant: counts this uneven, or more uneven, would turn up about 90 times in 100 sets of 96 fair rolls. The category table shows the 12 on the first face contributes most of what little discrepancy there is.

Goodness of fit against proportions. A sample of 100 buyers splits 45, 35, 20 across three products, against expected market shares of 50%, 30% and 20% (expected counts 50, 30, 20). The contributions are 0.50, 0.83 and 0.00, the statistic is 1.33 on 2 degrees of freedom, and p = 0.5134. The sample is consistent with the market shares; the middle product’s extra five buyers are the largest single contribution and they are still well within ordinary sampling wander.

Independence in a 2 by 2 table. Group 1: 30 with the outcome, 20 without. Group 2: 15 with, 35 without. Expected counts under independence are 22.5 and 27.5 in each row. The statistic is 9.09 on 1 degree of freedom, p = 0.0026, so the outcome rate is not independent of the group. Cramér’s V is 0.30, a moderate association. In plain rates the groups are 60% against 30%; if you need the relative risk and odds ratio for a table like this, the Statistical Test Calculator linked below reports them alongside its chi-square mode.

Reading the table the other way. With 5 degrees of freedom, the critical value at the 5% level is 11.07: a goodness-of-fit statistic on six categories has to pass 11.07 before it counts as significant at 5%. With 10 degrees of freedom the 5% critical value is 18.31, and with 1 degree of freedom it is 3.84. The lookup mode also confirms the independence example from the statistic’s side: a chi-square of 9.09 on 1 degree of freedom has 0.0026 of the distribution to its right and 0.9974 to its left.

Reading your result

The verdict compares the p-value with the significance level you set and states the conclusion in plain words. Below it, the category or cell detail is where the explanation lives: the largest contributions point at exactly which categories or cells disagree with the null hypothesis, and by how much. A significant result with one dominant contribution is a different story from a significant result spread thinly everywhere, and the table lets you tell them apart. For the independence test, Cramér’s V says how strong the association is on a 0 to 1 scale, which the p-value alone never does; with a large enough table of counts, a trivial association can still produce a very small p-value.

Limitations

  • Expected counts must not be tiny. The working rules are that no expected count should be below 1, and no more than about a fifth of them should be below 5. The result prints the smallest expected count so you can check. With small counts, combine sparse categories where that makes sense, or use an exact test; for a 2 by 2 table that is Fisher’s exact test, which is not computed here.
  • Counts, not percentages, rates or measurements. The test statistic is built from raw counts and their totals. Percentages without the underlying counts cannot be tested, and continuous measurements (heights, times, scores) belong in tests for means, not here.
  • Observations must be independent. Each counted item should appear once, in one category or cell. The same person counted twice, or before-and-after counts from the same subjects, break the assumption; paired categorical data has its own test (McNemar’s), which is not computed here.
  • Association is not cause. A significant independence test says the classifications move together in your data. It says nothing about which one drives the other, or whether a third factor drives both.
  • The lookup is the standard distribution. P-values and critical values come from the chi-square distribution itself, computed to the precision shown. Printed tables round to fewer digits, so a value read from a book can differ in the last place from the one shown here.

Frequently asked questions

What is the difference between goodness of fit and independence?

Goodness of fit has one classification and an expected pattern to compare it with: do these counts match the shares we expected? Independence has two classifications of the same items and no fixed pattern: the expected counts are built from the table’s own row and column totals, and the question is whether the two classifications are related. Same statistic, different null hypothesis, different degrees of freedom.

Why can I not just enter percentages?

Because the statistic weighs each squared difference by the expected count, and percentages throw the counts away. A split of 60/40 out of 10 cases gives a statistic of 0.40 against equal expectations; the same 60/40 split out of 10,000 cases gives 400. The percentages are identical and the evidence is not remotely the same. Convert percentages back to counts out of their true totals and the test works as it should.

What does an expected count below 5 actually break?

The p-value comes from a smooth distribution that approximates how the statistic behaves. When expected counts are tiny, the real behaviour of the statistic is lumpier than the approximation, and the printed p-value can be off in either direction. The flag in the results is a warning about the approximation, not about your data. Combining sparse categories, collecting more data, or switching to an exact test are the standard fixes.

How do I know the degrees of freedom?

You rarely choose them directly; the design sets them. Goodness of fit: categories minus 1. Independence: (rows minus 1) times (columns minus 1), so a 2 by 2 table has 1 and a 3 by 4 table has 6. They matter because the chi-square distribution changes shape with them: the same statistic of 9.09 is highly significant on 1 degree of freedom (p = 0.0026) and unremarkable on 8.

Is a very small chi-square statistic suspicious?

It can be. A statistic near zero means the counts match expectations almost perfectly, which real sampling rarely does; that is why the lookup mode also shows the lower tail. A lower-tail probability extremely close to 0 is the formal version of “too good to be true”, and in published research it has historically been a flag for smoothed or invented data. For ordinary use it usually just means a small sample behaving itself.

Related calculators

Method: Pearson’s chi-square statistic, summed as (observed minus expected) squared over expected; expected counts under independence as row total times column total over grand total; p-values and critical values from the chi-square distribution by the regularized incomplete gamma function and its inverse. All fixtures verified against independently computed values. Last reviewed: 22 October 2026.