TL;DR: The choice is decided by your data, not by preference. If your data falls into categories — yes/no, pass/fail, brand chosen — use the chi-square test, which compares counts. If your data is measurements on a scale — heights, test scores, times — and you want to compare averages, use the t-test. Using a t-test on categories, or a chi-square test on measurements, gives an answer that means nothing.
Two of the most common statistical tests are the chi-square test and the t-test, and beginners often mix them up. Both give you a p-value, both are used to test whether a pattern is real, and both appear in almost every introductory statistics course. But they answer different questions about different kinds of data, and picking the wrong one is one of the most common mistakes in applied statistics.
This guide compares the two tests side by side, works through one example of each with real numbers, and explains the mistake to avoid. For the full background on each test, see what the chi-square test is. You can run either test on your own data with our free Chi-Square Calculator and T-Test Calculator.
The one question that decides it
Ask yourself: what kind of data do I have? If the answer is categories — things that fall into named boxes — the chi-square test is your test. Favourite colour, yes/no answers, pass/fail, brand chosen, preferred drink: all categories. The chi-square test counts how many observations fall in each box and compares those counts with what you would expect.
If the answer is measurements — numbers on a scale where the size of the gap matters — the t-test is your test. Heights, weights, test scores, reaction times, prices: all measurements. The t-test compares the averages of two groups and asks whether the gap between them is bigger than the natural spread of the data would explain.
That is the whole decision in one sentence: categories go to chi-square; measurements and averages go to the t-test.
| Chi-square test | T-test | |
|---|---|---|
| Data type | Categorical (counts in boxes) | Numerical (measurements on a scale) |
| Question it answers | Do the counts match what was expected? | Do the two averages really differ? |
| What it compares | Observed counts vs expected counts | Two group means, against the spread |
| Typical data | Survey answers, pass/fail, preferences | Test scores, heights, times, weights |
| Test statistic | χ² | t |
| Needs | Raw counts; expected counts mostly 5+ | Roughly normal data; independent groups |
Example 1: chi-square — shopping habit by age group
A shop surveys 120 customers, asking whether they shop mostly online or in store, and records whether each customer is under 30 or 30 and over. The results are:
| Online | In store | Row total | |
|---|---|---|---|
| Under 30 | 42 | 18 | 60 |
| 30 and over | 28 | 32 | 60 |
| Column total | 70 | 50 | 120 |
Younger customers lean online (42 out of 60) while older customers split almost evenly. The chi-square test of independence checks whether that difference is real. The expected counts, from (row total × column total) / grand total, are 35 online and 25 in store for each age group. The four (O − E)² / E terms are 1.40, 1.96, 1.40 and 1.96, giving χ² = 6.72 with df = 1. The critical value at 5% is 3.841, and 6.72 is above it (p-value about 0.01), so the association is significant: in this sample, shopping habit really does differ by age group. A t-test could never answer this question, because there is no average to compare — only counts in boxes. The full step-by-step method is in the chi-square test of independence guide.
Example 2: t-test — exam scores of two classes
Now suppose two classes of 30 students each take the same exam. Class A averages 74 marks and Class B averages 69 marks. Is Class A really better, or is a 5-mark gap the kind of difference that appears by chance between any two classes?
This is a t-test question, because the data is measurements (marks out of 100) and the question is about averages. The t-test takes the 5-mark gap between the means and judges it against the spread of the scores within each class: if the scores in each class are tightly bunched, a 5-mark gap is strong evidence; if the scores are spread all over the range, the same 5-mark gap could easily be chance. The test produces a t value and a p-value, and a p-value below 0.05 means the gap is unlikely to be chance.
A chi-square test could never answer this question either. It has no way to use the actual marks — it could only count how many students fell into boxes like “pass” and “fail”, throwing away all the information about how far above or below the line each student scored.
The common mistake: using a t-test on categories
The most common mistake is coding categories as numbers and running a t-test on them. Suppose a survey asks people whether they prefer coffee or tea, and someone codes coffee as 1 and tea as 2, then averages the answers to get 1.4. That number means nothing: there is no such thing as “1.4 drinks”, and the average of two labels is not a measurement. A t-test on those numbers produces a p-value that looks scientific but answers no real question.
The reverse mistake is just as bad: turning measurements into categories to run a chi-square test. Splitting exam scores into “pass” and “fail” and testing the counts throws away the difference between a student who scored 51 and one who scored 99. If you have the raw measurements, use them — the t-test is built for exactly that.
There is one honest middle ground: sometimes the categories are the question. If the school only cares about pass rates, not average marks, then pass/fail is the right data and the chi-square test is the right test. The mistake is not choosing categories; it is choosing them by accident, after collecting measurements that could have answered a sharper question.
Quick checklist before you choose
- What is each observation? A category (coffee, tea) or a measurement (74 marks)? Categories point to chi-square; measurements point to the t-test.
- What are you comparing? Counts against expected counts, or two averages against each other?
- How many groups? A t-test compares two groups; the chi-square test handles two or more categories on each side.
- Do you have raw counts or raw measurements? The chi-square test needs counts, the t-test needs the measurements themselves — not summaries, and never percentages in place of counts.
If you can answer the first question, you have made the decision. Everything else is just working through the test you chose.
Frequently Asked Questions
How do I choose between a chi-square test and a t-test?
Look at your data. If it falls into categories — yes/no, pass/fail, brand chosen — use a chi-square test. If it is measurements on a scale — heights, scores, times — and you want to compare averages, use a t-test.
Can I use a t-test on survey answers like yes/no?
No. Yes/no answers are categorical data, and a t-test needs measurements it can average. Use a chi-square test for yes/no data, or a test built for comparing proportions.
Can I use a chi-square test on test scores?
Only if you first group the scores into categories, such as pass/fail — but that throws away information. Comparing the raw scores with a t-test is usually the better choice.
What does each test actually compare?
A chi-square test compares the counts you observed in categories with the counts you expected. A t-test compares the averages of two groups, judging the gap against the spread of the data.
Do both tests use a p-value?
Yes. Both tests give a p-value, and 0.05 is the usual cut-off in both cases. A p-value below 0.05 means the pattern is unlikely to be chance; above it, the sample does not provide enough evidence.
References
- 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
- Illowsky, Barbara & Dean, Susan (2023). Introductory Statistics 2e. OpenStax, Rice University. Chapter 11, "The Chi-Square Distribution". Source
- Student [William Sealy Gosset] (1908). "The probable error of a mean." Biometrika, 6(1), 1–25. Source