Chi-square test vs t-test: which to use
By Jude Wallis · Published
A chi-square test analyzes counts of categorical data, asking whether a distribution differs across groups or whether two variables are associated. A t-test analyzes means of quantitative data. If each individual gives a category, use chi-square; if each gives a number you can average, use a t-test.
This page spans two units of the Fall 2026 AP Statistics course. Chi-square tests for homogeneity and independence are Unit 3 topics 3.14 and 3.15, and t-tests for means are in Unit 4, with the one-sample test carried out in topic 4.5 and the two-sample test in topic 4.10. The chi-square goodness-of-fit test is not part of the Fall 2026 framework, so the chi-square material here is limited to two-way tables.
Chi-square test vs t-test: the short answer
The choice depends on the response variable.
A chi-square test is for categorical data. Each individual falls into a category, the data are summarized as counts in a table, and the test asks whether those counts differ from what a null hypothesis of no difference or no association would produce.
A t-test is for quantitative data. Each individual contributes a number, the data are summarized by a mean and a standard deviation, and the test asks whether a population mean equals a claimed value or whether two population means differ.
The two never compete for the same variable. You cannot average categories such as "home" and "library," so a t-test has nothing to work with there. A chi-square test run on quantitative data would first have to cut the numbers into categories, which discards information the t-test uses.
The chi-square test
In the AP course a chi-square test starts from a two-way table of counts. There are two versions with the same arithmetic. The test for homogeneity compares the distribution of one categorical variable across two or more populations or treatments. The test for independence asks whether two categorical variables are associated in one population.
For each cell, compute the expected count under the null hypothesis,
and then the statistic
The statistic is a sum of squared terms, so it is never negative. Its reference curve is a chi-square distribution, which is skewed right, with degrees of freedom. The p-value is always the area in the upper tail. The hypotheses are written in words, and the alternative has no direction: it says only that the distributions differ or that an association exists.
Conditions: random samples or a randomized experiment, the 10% condition when sampling without replacement, and all expected counts greater than 5. The full procedure is in chi-square tests explained.
The t-test
A t-test compares means. The one-sample version tests with
and degrees of freedom, where ("x-bar") is the sample mean and is the sample standard deviation. The two-sample version tests with
and degrees of freedom from technology.
The statistic counts standard errors from the null value and can be positive or negative. Its reference curve is a distribution, which is symmetric about 0. The hypotheses are written in symbols about ("mu"), and the alternative can be one-sided or two-sided, so the p-value may come from one tail or both.
Conditions: a random sample or randomized experiment, the 10% condition when sampling without replacement, and a normality check: the population is stated to be approximately normal, or the sample size is at least 30, or a smaller sample shows no strong skew or outliers. Step-by-step versions are in one-sample t-test step by step.
The differences side by side
| Feature | Chi-square test | t-test |
|---|---|---|
| Type of data | Categorical | Quantitative |
| Data summary | Counts in a two-way table | Mean and standard deviation |
| What is tested | Equal distributions, or no association | A mean, or a difference of two means |
| Hypotheses | Stated in words | Stated with |
| Statistic | ||
| Sign of the statistic | Never negative | Positive or negative |
| Reference curve | Chi-square, skewed right | , symmetric |
| Tails for the p-value | Upper tail only | One or two, set by |
| Degrees of freedom | , or from technology for two samples | |
| Size condition | All expected counts greater than 5 | Normal population, , or no strong skew or outliers |
The degrees of freedom show the contrast clearly. For a t-test they grow with the sample size. For a chi-square test they depend on the dimensions of the table and stay the same however many individuals are counted.
When to use which
Ask what was recorded for one individual.
- A category, such as a preference, a yes or no, or a group label: the analysis is about counts and proportions. With a two-way table of counts, use a chi-square test.
- A number with units, such as hours, points, or centimeters: the analysis is about means. Use a t-test.
Then match the design. For quantitative data, one sample against a claimed value is a one-sample t-test, and two independent groups is a two-sample t-test. For categorical data, separate samples or treatment groups compared on one variable is a chi-square test for homogeneity, and one sample classified two ways is a chi-square test for independence.
Categorical data with only two outcomes and one or two groups can also be handled with a z-test for proportions, which allows a one-sided alternative. The t-test still does not apply, because the response is a category. The wider map of procedures is in which statistical test to use and the which test interactive.
The classic mix-up and how to avoid it
The first error is letting numbers in the problem choose the test. A two-way table is full of numbers, yet they are counts of categories, and averaging them is meaningless. A related error is coding categories as 1, 2, 3 and running a t-test on the codes. The codes are labels, and their mean has no interpretation.
The second error is feeding a chi-square test the wrong inputs: means, percentages, or proportions in the cells. The statistic is defined for counts. Entering percentages in place of counts generally changes its value, and the p-value with it.
The third error is borrowing features across tests: looking for a negative chi-square statistic, doubling a chi-square p-value for a two-sided test, or writing chi-square hypotheses about . A chi-square test has one tail and no direction.
To avoid these, name the response variable and its type before anything else. "Preferred study location, categorical" leads to counts and chi-square. "Weekly homework hours, quantitative" leads to means and . The distinction is laid out in qualitative vs quantitative data.
A quantitative response: two-sample t-test
A large school takes independent random samples of 40 ninth graders and 40 twelfth graders. Weekly homework time for the ninth graders has hours and hours; for the twelfth graders, hours and hours. Test at whether mean homework time differs between the grades.
Identify the response. Weekly homework time is a number of hours for each student, a quantitative variable, so compare means with a two-sample t-test.
State the hypotheses: and , where and are the mean weekly homework times of all ninth graders and all twelfth graders at the school.
Check conditions: independent random samples, each under 10% of its grade at a large school, and both sample sizes are 40, which is at least 30.
Variance terms: and .
Standard error: .
Test statistic: .
Degrees of freedom from technology: 75.54. The two-sided p-value is 0.0262. Since , reject .
with 75.54 degrees of freedom and a p-value of 0.0262. Reject : there is convincing evidence that mean weekly homework time differs between ninth graders and twelfth graders at this school. The data were numbers, so the test compared means.
A categorical response from the same students: chi-square test
The same 80 students are asked where they usually study. Ninth graders: 24 at home, 10 at a library, 6 somewhere else. Twelfth graders: 16 at home, 18 at a library, 6 somewhere else. Test at whether the distribution of study location differs between the grades.
Identify the response. Study location is a category for each student, so the data are counts. With independent samples from two populations and one categorical variable, use a chi-square test for homogeneity.
State the hypotheses. : the distribution of study location is the same for ninth graders and twelfth graders at the school. : the distributions differ.
Find the totals. Rows: 40 and 40. Columns: home, library, other. Table total: 80.
Expected counts, the same for both rows because the row totals match: , , . All are greater than 5.
Ninth grade terms: , , .
Twelfth grade terms: , , .
Add: .
Degrees of freedom: . The p-value, the area to the right of 3.8857, is 0.1433. Since , fail to reject .
with 2 degrees of freedom and a p-value of 0.1433. Fail to reject : the samples do not give convincing evidence that the distribution of study location differs between the two grades. The same 80 students called for a t-test when the response was hours and a chi-square test when the response was a category.
Frequently asked questions
Can I use a t-test on categorical data?
No. A t-test compares means, and categories have no mean. Assigning number codes to categories does not fix this, because the codes are arbitrary labels. Use a chi-square test for a two-way table of counts, or a z-test for proportions when the response has two outcomes.
Can a chi-square statistic be negative?
No. Each term is a squared difference divided by a positive expected count, so the statistic is 0 or greater. A statistic can be negative, because it keeps the sign of the difference between the sample result and the null value.
Why is a chi-square test always one-tailed?
Squaring removes the direction of each difference, so every kind of departure from the null hypothesis makes the statistic larger. Evidence against therefore always sits in the upper tail. A t-test keeps direction, so its alternative can be one-sided or two-sided.