Professor Turing

Study guides

What is a t test?

Last updated: 2026-11-23

A t test asks whether a difference in means is big compared with the noise you would expect from the sample itself. It divides the difference by an estimate of that noise, called the standard error. It turns that into a t statistic, and then reads a p-value from the t distribution. It is the version of a hypothesis test you use when the spread of the data is not known and has to be estimated from the sample.

Start learning No account needed

1. Three versions, and how to choose

A one-sample t test compares one group's mean with a number, such as a claimed average. A two-sample t test compares the means of two separate groups. A paired t test compares two measurements that belong together, such as the same plant before and after, or two matched plots in a pair. Each version computes a difference and divides by a standard error, and what changes is where the standard error comes from.

The choice follows from how the data were collected. If each value in one group has a specific partner in the other group, the data are paired. If the groups are unrelated, they are independent. The formula sheet rarely says which one you have, and section 3 shows what goes wrong when the choice is made the wrong way.

2. A worked example: ten seedlings, two groups

You grow ten seedlings and measure their heights in centimeters after a month. Five got a fertilizer: 14, 16, 15, 18 and 17. Five did not: 12, 15, 13, 16 and 14. The means are 16 and 14, a gap of 2 cm. H0 is that the true means are equal, and you choose alpha 0.05 before looking.

GroupValuesMeanSquared deviationsSum
Fertilizer14, 16, 15, 18, 17164, 0, 1, 4, 110
No fertilizer12, 15, 13, 16, 14144, 1, 1, 4, 010

Treat the groups as independent and pool their spread. The pooled variance is (10 + 10) / (5 + 5 − 2) = 2.5. The standard error of the gap is √(2.5 × (1/5 + 1/5)) = 1.00, so t = 2.00 / 1.00 = 2.00 with 8 degrees of freedom. The two-sided cutoff for 8 degrees of freedom at alpha 0.05 is 2.306, and 2.00 falls short of it. The p-value is 0.0805, so you fail to reject H0. A 2 cm gap with five seedlings per group is not enough to rule out chance, though it does not show the fertilizer does nothing.

The one-sample version works the same way. Compare the fertilizer group with a claimed mean of 15. The group's standard deviation is 1.58, so the standard error is 1.58 / √5 = 0.71, t = 1.00 / 0.71 = 1.41 with 4 degrees of freedom, and the p-value is 0.2302.

3. The same numbers as pairs

Now suppose the ten seedlings were grown in five side-by-side pairs, one seedling in each pair with fertilizer, in the order listed above. Then the data are paired, and you work with the differences within each pair: 14 − 12, 16 − 15, 15 − 13, 18 − 16 and 17 − 14, which are 2, 1, 2, 2 and 3. Their mean is 2.0 and their standard deviation is 0.71, so the standard error is 0.71 / √5 = 0.32. That gives t = 2.0 / 0.32 = 6.32 with 4 degrees of freedom. The cutoff for 4 degrees of freedom is 2.776, and the p-value is 0.0032, so you reject H0.

The gap of 2 cm did not change. What changed is the noise. Within a group the heights vary with a standard deviation of 1.58, but within a pair the differences vary with a standard deviation of only 0.71, because seedlings grown together share light, soil and water. Pairing removes that shared variation, and the test sees a 2 cm gap against much less noise. The script givestwo-sample t = 2.00, df = 8, p = 0.0805 and paired t = 6.32, df = 4, p = 0.0032. They come from a short script, t-test-example.mjs, that does the same arithmetic.

4. A common misconception: use the paired test when it gives the smaller p-value

Having seen 0.0805 and 0.0032 side by side, it is tempting to try both and report the smaller. Pairing is a fact about how the data were collected, though, and not a setting for the analysis. Two values are a pair only if something real ties them together, such as the same subject, the same plot or a matched design, and that is decided before the data come in.

To see why, keep the same ten heights but pair the fertilizer values with the other group's values in a different order: 16, 12, 14, 15 and 13. The differences become −2, 4, 1, 3 and 4, the mean difference is still 2, but the standard deviation of the differences is 2.55, and t = 1.75 with 4 degrees of freedom and a p-value of 0.1543. The same ten numbers now give a p-value about 48 times larger, because the pairing no longer matched anything real. The p-value from the paired test is only meaningful when the pairs are.

The mistake can go the other way, too. If the data really are paired, running a two-sample test throws away the matching and reports 0.0805 where the data support 0.0032.

5. Test yourself

Close this page and, for each of these, say which t test you would use and why: the same ten students tested before and after a course; the scores of two different classes; one class's mean score compared with the national average. Then reopen the page and compare. The first case you hesitated on is the part to study again.

The cutoff and the p-value are explained in what is hypothesis testing and what is a p-value. For the general method, see how to test yourself.

What the sources found, and their limits

NIST/SEMATECH e-Handbook of Statistical Methods, sections 7.2.2 and 7.3.1. NIST, the U.S. National Institute of Standards and Technology. It gives the one-sample statistic with the sample standard deviation and n - 1 degrees of freedom, the two-sample statistic with a pooled standard deviation and n1 + n2 - 2 degrees of freedom when the spreads can be taken as equal, the Welch version when they cannot, and the rule of using a z statistic only when the standard deviation is known. Sources: 7.2.2, Are the data consistent with the assumed process mean? and 7.3.1, Do two processes have the same mean?, read on 2026-11-23.

Introduction to Modern Statistics, chapters 19 to 21. Mine Çetinkaya-Rundel and Johanna Hardin, OpenIntro, second edition. It supports the conditions we state (independent observations, and no clear outliers when the sample is small), the t distribution having thicker tails than the normal, and paired data being a structure of the study that is analyzed through the within-pair differences, much like a one-sample test. Sources: Inference for a single mean and Inference for comparing paired means, read on 2026-11-23. Limits: the book's two-sample method does not pool the spreads, and we use the pooled version because NIST gives it and it keeps the arithmetic short. We did not check the claim that a wrong pairing inflates the p-value against a source, so it rests on the worked numbers alone. The seedlings and all figures on this page are ours, made up to show the arithmetic.

How Professor Turing helps

Professor Turing is a tutor for adults learning any subject, in college or on their own. It asks you questions instead of giving the final answer, does not grade a bare guess, and remembers what you got wrong. No account is needed to start.

Bring a topic you are studying, such as when a t test should be paired. Its first reply asks what you already know before it teaches anything. If you answer with a bare guess, such as a term, it asks how you got there instead of saying right or wrong, and when you stay stuck it changes its approach and makes the next step smaller instead of giving the final answer. Later in a session it can offer a short test without help, scored apart from the tutoring, so you can tell what you can do alone from what the tutor carried you through.

It does not read or mark a written answer, and it does not write your explanation for you, so the explanation has to be yours. You must be 18 or older, and conversations are deleted after 7 days.

FAQ

Why use a t test instead of a z test? A z test uses a spread that is known in advance. A t test estimates the spread from the sample, which adds uncertainty, so it uses the t distribution, whose tails are heavier for small samples. In our example the two-sided cutoff at alpha 0.05 is 2.306 with 8 degrees of freedom, against 1.96 for a z statistic, so the same t value of 2.00 is not enough to reject.

What does a t test assume? It assumes the values are independent of each other (apart from the pairing in a paired test) and come from roughly bell-shaped distributions, and the two-sample version in our example also assumes the groups have a similar spread. With samples as small as five per group, one extreme value can change the result a lot, so look at the data before you rely on the number.

Start with what you're working on

Tell the tutor which topic you are studying and let it ask you the questions.

Start learning No account needed

See also: all study guides