What Is the Chi-Square Test? A Plain-English Guide

TL;DR: The chi-square test compares the counts you actually observed in categories with the counts you would expect if nothing interesting were going on. If the two match closely, there is nothing to report; if they differ a lot, the pattern is probably real. It works on counts in categories — survey answers, yes/no results, pass/fail — never on averages or measurements. A large chi-square value means a bigger gap between observed and expected counts.

Suppose you survey 200 people about whether they prefer coffee or tea, and 130 say coffee. Is that a real preference, or could it just be chance? Or suppose men and women in your survey seem to answer differently — is the gap real, or is it the kind of wobble you would see in any random sample? The chi-square test is the standard tool for questions like these. It is one of the most common tests in statistics, and it is far simpler than it looks.

This guide explains it in plain English: what it tests, how the number is worked out, what degrees of freedom mean, and when it is the right tool — and when it is not. You can check every example with our free Chi-Square Calculator.

What is the chi-square test?

The chi-square test (written χ², pronounced “ky-square”) is a statistical test that works with counts in categories. It asks one question: are the counts I observed different enough from the counts I expected that something real is going on?

“Expected” means the counts you would see if there were no pattern at all. If you flip a fair coin 100 times, you expect about 50 heads and 50 tails. If you actually get 52 heads and 48 tails, that is close to expected, and the test says: nothing surprising here. If you get 90 heads and 10 tails, the gap is far too big for chance, and the test says: this coin is probably not fair.

The test comes in two main forms. The goodness-of-fit test checks one variable against the counts you expect — for example, whether a die is fair. The test of independence checks whether two categorical variables are related — for example, whether drink preference depends on gender. Both use the same statistic and the same idea: compare observed counts with expected counts.

One thing the test never does is explain why a pattern exists. It can tell you that men and women in your sample answered differently; it cannot tell you the reason. That part is always up to you.

What kind of data does the chi-square test use?

The chi-square test works on categorical data — data that falls into named groups. Favourite colour, yes/no answers, pass/fail, brand chosen, blood group, preferred drink: all of these are categories. The test counts how many observations fall in each group and compares those counts with the expected counts.

It does not work on measurements such as height, weight, test scores or time taken, because those are numbers on a scale, not counts in boxes. If your data is a list of measurements and you want to compare averages, you need a t-test instead. If you are not sure which one fits your data, the guide on the chi-square test vs t-test walks through the decision.

Three conditions matter before you run the test. First, the data should come from a random sample. Second, each observation should be independent — one person counted once, not the same person counted twice. Third, the expected count in each category should usually be 5 or more; with very small expected counts the test becomes unreliable.

The chi-square statistic, in plain words

The test boils the whole comparison down to a single number, the chi-square statistic, written χ². The formula is:

χ² = Σ (O − E)² / E

In words: for every category, take the observed count (O), subtract the expected count (E), square the difference, divide by the expected count — then add up the results for all categories. The Σ symbol simply means “add them all up”.

Each part of the formula has a job. Subtracting O − E measures how far off each category is. Squaring the difference makes every gap positive, so a category that is too high and one that is too low cannot cancel each other out — and it punishes big gaps much more than small ones. Dividing by E keeps the measure fair: a gap of 10 matters far more when you expected 20 than when you expected 2,000.

A small χ² value, close to zero, means the observed counts match the expected counts closely. A large χ² value means a big mismatch somewhere. Here is a one-category example: suppose you expected 25 people to pick option A, but 30 actually did. That category contributes (30 − 25)² / 25 = 25 / 25 = 1.00 to the total. If every category is about that far off, the total stays small; if some categories are far off, the total grows quickly.

Degrees of freedom, explained simply

To judge whether a χ² value is large, you need to know the degrees of freedom (df). Roughly speaking, this is the number of categories that are free to vary once the totals are fixed. A table with more categories has more room to wobble by chance, so the same χ² value means different things at different degrees of freedom — which is why you always report them together, for example “χ² = 4.51, df = 1”.

The rules are simple. For a goodness-of-fit test with k categories, df = k − 1. A die has 6 faces, so a test of whether it is fair has df = 5. For a test of independence on a table with r rows and c columns, df = (r − 1) × (c − 1). A 2×2 table has df = 1, and a 3×4 table has df = 6.

When should you use a chi-square test?

The test fits best when your question is about counts in categories. Typical cases include: does preference differ between two groups? Do the observed counts match a claimed split, such as equal shares or a 50/50 split? Is there an association between two categorical variables, such as age group and shopping habit?

It is popular in survey analysis, market research, quality control and genetics, because so much real-world data arrives as categories. It is also easy to explain to a non-technical audience: the whole argument is “here is what we saw, here is what we would expect by chance, and here is how far apart they are.”

When should you NOT use a chi-square test?

First, do not use it on numerical data. If you want to compare average heights, average scores or average times, use a t-test, not a chi-square test. Turning measurements into categories just to run a chi-square test throws away information.

Second, do not use it when the expected counts are tiny. If many categories have an expected count below 5, the test’s maths breaks down; combine small categories where that makes sense, collect more data, or use Fisher’s exact test for a small 2×2 table.

Third, do not feed it percentages. The test needs raw counts — 60 out of 100, not 60%. Two surveys can both show 60% yet carry very different amounts of evidence if one surveyed 100 people and the other surveyed 10.

Finally, do not use it on paired or repeated data, such as the same people measured before and after a change. That needs a test built for paired data, such as McNemar’s test.

How do you read the result?

Once you have χ² and the degrees of freedom, there are two ways to judge the result. The classic way is to compare χ² with a critical value from a chi-square table for your degrees of freedom. At the usual 5% significance level, a 2×2 table (df = 1) has a critical value of 3.841: a χ² above 3.841 means the result is statistically significant.

The modern way is the p-value, which is the probability of seeing a gap this big purely by chance. A p-value below 0.05 is the usual cut-off: below it, the gap is unlikely to be chance, so you conclude the pattern is real. Above it, you do not have enough evidence to say so.

Either way, remember what a significant result does and does not say. It says the counts differ from expectation more than chance would explain. It does not say how big the difference is in practical terms, and it does not say why it happened. For the size of the effect, look at the counts themselves — a 5-point gap in percentages may be significant with a huge sample and still too small to matter.

Frequently Asked Questions

What does a chi-square test tell you?

A chi-square test tells you whether the counts you observed in categories differ from the counts you expected by more than chance alone would explain. It does not tell you why the pattern exists, or how strong it is — for that, look at the counts themselves.

What is the difference between observed and expected frequencies?

Observed frequencies are the counts you actually got — for example, 60 men chose coffee and 40 chose tea. Expected frequencies are the counts you would get if there were no pattern at all, worked out from the row and column totals of your table.

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

Degrees of freedom are roughly the number of values in your table that are free to vary once the totals are fixed. For a goodness-of-fit test with k categories, df = k - 1. For a test of independence on a table with r rows and c columns, df = (r - 1) x (c - 1).

Can I use a chi-square test on numbers like test scores?

No. Test scores are measurements on a scale, and the chi-square test only works with counts in categories. To compare the average scores of two groups, use a t-test instead.

What is a good chi-square value?

There is no single good value — it depends on the degrees of freedom. Compare your chi-square value with the critical value for your degrees of freedom, or check the p-value. Above the critical value at the 5% level, the result is statistically significant.

References

  1. Pearson, Karl (1900). "On the criterion that a given system of deviations from the probable in the case of a correlated system of variables is such that it can be reasonably supposed to have arisen from random sampling." Philosophical Magazine, Series 5, 50(302), 157–175. Source
  2. Illowsky, Barbara & Dean, Susan (2023). Introductory Statistics 2e. OpenStax, Rice University. Chapter 11, "The Chi-Square Distribution". Source