A t-test tells you whether the difference between two averages (or between one average and a target value) is too big to blame on random chance. It works with small samples and doesn’t need you to know the population’s standard deviation, which is why it shows up everywhere from school science projects to medical studies.
Say one class scores 83 on a quiz and another scores 75.4. Is that a real difference, or would you see a gap like that just by picking different students? A t-test answers that question with a single number, the t statistic, and a p-value.
Below you’ll find what a t-test is, the three main types, the formulas in plain words, a full worked example with real arithmetic, and an interactive chart you can play with.
Quick Info
| Topic | Detail |
|---|---|
| Short definition | A test that compares means using the t distribution |
| Main types | One-sample, two-sample (independent), paired |
| Key formula | t = difference in means ÷ standard error |
| Output | t statistic, degrees of freedom, p-value |
| Common mistake | Using a two-sample test on paired (before/after) data |
| Best use | Comparing means when σ is unknown, especially with small samples |
| Reading time | About 10 minutes |
What Is a T-Test?
In one sentence: a t-test compares a sample mean with a target value, or two means with each other, by measuring the difference in units of standard error and checking it against the t distribution.
Like every hypothesis test, it starts with a null hypothesis (H₀) that says “there’s no difference.” The test then asks how surprising your data would be if H₀ were true. A very surprising result gives a small p-value, and you reject H₀.
The “t” comes from the t distribution, a bell-shaped curve with heavier tails than the normal distribution. Those heavier tails account for the extra uncertainty you have when you estimate the spread from a small sample. As the sample grows, the t curve slims down until it’s almost identical to the normal curve.
The method was published in 1908 in the journal Biometrika under the pen name “Student,” which is why you’ll often see it called Student’s t-test.
Source: Student, “The Probable Error of a Mean,” Biometrika (1908).
T-test vs z-test
| T-test | Z-test | |
|---|---|---|
| Population standard deviation (σ) | Unknown, estimated from the sample | Known |
| Reference curve | t distribution (shape depends on df) | Standard normal curve |
| Sample size | Any, but built for small samples | Usually large |
| How often you’ll use it | Very often in real research | Mostly in textbook problems |
In real life you almost never know σ, so the t-test is the one you’ll actually use. If you’re comfortable with z-scores, think of the t statistic as a z-score that has been made a little more cautious.
The 3 Types of T-Tests
The right t-test depends on how your data were collected. Ask yourself one question first: are the two sets of numbers from the same people, or from different people?
1. One-sample t-test
This compares one group’s mean with a fixed number. A juice factory fills bottles labeled 500 mL and weighs 10 of them. Is the average fill different from 500 mL? With the 10 fills in our t-test calculator example (mean 502 mL, standard deviation 2.58 mL), t = 2.45 with 9 degrees of freedom and p ≈ 0.037, so at α = 0.05 the bottles are slightly overfilled. (Illustrative numbers.)
2. Two-sample (independent) t-test
This compares the means of two separate groups, like two classes, two fertilizers or two website designs. Nobody belongs to both groups. There are two versions: Welch’s t-test, which doesn’t assume the groups have the same spread, and the pooled t-test, which does. Welch’s is the safer default and is the one used in the worked example below.
3. Paired t-test
This is for two measurements on the same subjects, such as before and after a training program, or left and right hands. You subtract each pair to get a list of differences, then run a one-sample t-test on those differences against 0.
OpenStax describes it the same way: the differences are the data, and they’re tested with a Student’s t-test for a single mean with n − 1 degrees of freedom, where n is the number of pairs.
Source: OpenStax, Introductory Statistics 2e, “10.4 Matched or Paired Samples”.
| Type | Compares | Degrees of freedom | Example |
|---|---|---|---|
| One-sample | One mean vs a target value | n − 1 | Average bottle fill vs 500 mL |
| Two-sample (Welch) | Means of two separate groups | Welch–Satterthwaite formula | Class A vs class B quiz scores |
| Paired | Mean of before/after differences vs 0 | pairs − 1 | Typing speed before and after practice |
The T-Test Formula, in Plain Words
Every t-test has the same shape: a difference on top, and the standard error of that difference underneath.
t = (observed difference) ÷ (standard error of that difference)
One-sample: t = (x̄ − μ₀) ÷ (s ÷ √n)
Welch: t = (x̄₁ − x̄₂) ÷ √(s₁²/n₁ + s₂²/n₂)
- x̄ is the sample mean, and μ₀ is the value you’re testing against.
- s is the sample standard deviation, and n is the sample size.
- x̄₁, s₁, n₁ and x̄₂, s₂, n₂ are the mean, standard deviation and size of each group.
Read it like a signal-to-noise ratio. The top is the signal (how far apart the means are). The bottom is the noise (how much the means would wobble from sample to sample). A t of 3.5 means the gap is 3.5 times bigger than the usual wobble.
For Welch’s test, the degrees of freedom come from the Welch–Satterthwaite formula, which blends both sample sizes and variances. The NIST/SEMATECH e-Handbook gives this formula and recommends it for unequal sample sizes or unequal variances.
Source: NIST/SEMATECH e-Handbook of Statistical Methods, “Two-Sample t-Test for Equal Means”.
Worked Example: Do Two Review Methods Give Different Quiz Scores?
A teacher tries two ways of reviewing for the same quiz. Class A (12 students) uses flashcards. Class B (10 students) rereads their notes. Here are the scores. (Illustrative numbers.)
| Class | Scores |
|---|---|
| A (flashcards, n = 12) | 78, 85, 82, 90, 74, 88, 81, 86, 79, 84, 92, 77 |
| B (rereading, n = 10) | 72, 80, 75, 70, 83, 76, 68, 79, 74, 77 |
Step 1: State the hypotheses
H₀: the two review methods give the same mean score (μ₁ = μ₂). H₁: the means are different (μ₁ ≠ μ₂). That makes it a two-tailed test. We’ll use α = 0.05.
Step 2: Find each mean and standard deviation
Class A: mean = 996 ÷ 12 = 83.0, standard deviation s₁ = 5.494. Class B: mean = 754 ÷ 10 = 75.4, standard deviation s₂ = 4.624. The gap is 83.0 − 75.4 = 7.6 points.
Step 3: Work out the standard error
s₁²/n₁ = 30.18 ÷ 12 = 2.515 and s₂²/n₂ = 21.38 ÷ 10 = 2.138. Add them and take the square root: √(2.515 + 2.138) = √4.653 = 2.157.
Step 4: Calculate t
t = 7.6 ÷ 2.157 = 3.52. The difference is about three and a half standard errors wide.
Step 5: Find the degrees of freedom and p-value
The Welch formula gives df = (2.515 + 2.138)² ÷ (2.515²/11 + 2.138²/9) ≈ 20.0. For t = 3.52 with 20 degrees of freedom, the two-tailed p-value is about 0.002.
Step 6: Decide and report
Because p ≈ 0.002 is less than 0.05, the teacher rejects H₀. In a report you’d write: the flashcard class scored higher (M = 83.0) than the rereading class (M = 75.4), Welch’s t(20.0) = 3.52, p = .002. The 95% confidence interval for the difference runs from about 3.1 to 12.1 points.
| Step | Working | Result |
|---|---|---|
| Difference in means | 83.0 − 75.4 | 7.6 |
| Standard error | √(2.515 + 2.138) | 2.157 |
| t statistic | 7.6 ÷ 2.157 | 3.52 |
| Degrees of freedom | Welch formula | ≈ 20.0 |
| p-value (two-tailed) | area beyond ±3.52 | ≈ 0.002 |
| Decision at α = 0.05 | 0.002 < 0.05 | Reject H₀ |
One honest caveat: a significant t-test shows the classes differ, not why. The flashcard class might also have been the stronger class to begin with. Random assignment is what lets you blame the review method.
Try It: What Makes a T-Test Significant?
Three things push t up: a bigger gap between the means, less spread in the data and more people in each group. Move the sliders to see how each one changes t and the p-value. The chart shows the t curve for your sample size, with the 5% rejection region shaded.
Assumes two independent groups of equal size and equal spread, two-tailed test, α = 0.05. Illustrative.
Notice that a gap of 4 points (with a spread of 8) is not significant with 8 people per group (p ≈ 0.33) but is significant with 40 (p ≈ 0.03). Sample size doesn’t change the real difference; it changes how sure you can be about it.
T-Test Assumptions: A Quick Checklist
| Assumption | What it means | If it fails |
|---|---|---|
| Random, independent data | Each value comes from a different, randomly chosen subject (or pair) | The p-value can’t be trusted; fix the design |
| Roughly normal data | The values (or differences) look roughly bell-shaped | With 30+ per group this matters much less; with tiny samples, check a histogram |
| No extreme outliers | No single value far away from the rest | One wild value can swing the mean and the t statistic |
| Equal variances (pooled test only) | Both groups have a similar spread | Use Welch’s t-test instead |
Common T-Test Mistakes and Myths
| Myth | Reality |
|---|---|
| “A significant t-test means the difference is big.” | It means the difference is unlikely to be zero. With large samples, a tiny, unimportant gap can still be significant. Look at the size of the difference and its confidence interval too. |
| “p > 0.05 proves the means are equal.” | It only means the evidence wasn’t strong enough. Small samples often miss real differences. |
| “Before-and-after data can use a two-sample test.” | Measurements on the same people are paired. A two-sample test ignores that link and usually loses a lot of power. |
| “You can run many t-tests to compare five groups.” | Each extra test adds another chance of a false alarm. Comparing three or more groups at once calls for ANOVA. |
| “The t-test needs a big sample.” | It was built for small samples. The catch is that small samples lean harder on the normality assumption. |
Frequently Asked Questions
What is a t-test used for?
A t-test checks whether a difference in averages is real or could easily be random noise. Typical uses include comparing two teaching methods, checking whether a product meets its labeled amount, testing a drug against a placebo, or measuring change before and after a program.
What does the t value tell you?
The t value is the difference you observed divided by its standard error. A t near 0 means the groups look alike. A t far from 0, such as below −2 or above 2 for moderate samples, suggests a difference that is unlikely to be chance. The p-value turns t into a probability.
What sample size do you need for a t-test?
There’s no fixed minimum; a t-test works with as few as two values per group. Small samples, though, only detect large differences and depend more on the data being roughly normal. A common rule of thumb is that around 30 per group makes the normality assumption much less of a worry.
When should you use a paired t-test instead of a two-sample t-test?
Use a paired test whenever each value in one set has a natural partner in the other: the same person measured twice, twins, or matched items. If the two groups are made of different, unrelated subjects, use a two-sample test.
What is the difference between a t-test and ANOVA?
A t-test compares at most two means. ANOVA compares three or more at once and controls the overall false-alarm rate. With exactly two groups, a one-way ANOVA and a pooled t-test give the same p-value.
Conclusion
A t-test compares means by asking how many standard errors apart they are, then reads that distance off the t distribution to get a p-value. Pick the one-sample test for a single group against a target, Welch’s two-sample test for two separate groups, and the paired test for before-and-after data. You can run all three in seconds with our free t-test calculator, or turn a t score into a p-value with the P-Value Calculator.
Rule of thumb to carry with you: signal over noise. The bigger the gap and the smaller the wobble, the bigger your t.
References
- Student, “The Probable Error of a Mean,” Biometrika, 1908. doi.org/10.1093/biomet/6.1.1
- NIST/SEMATECH, “Two-Sample t-Test for Equal Means,” e-Handbook of Statistical Methods. itl.nist.gov
- OpenStax, “10.4 Matched or Paired Samples,” Introductory Statistics 2e. openstax.org
Disclaimer
This article is for general educational purposes only. The quiz scores, bottle fills and typing speeds in the examples are illustrative. For research design or high-stakes analysis, consult a qualified statistician.