t-Tests (One-Sample, Independent, Paired)
Info sheet · Statistics for Psychology & Neuroscience
Warning✎ Editing notes — to do / to check
Working notes for the author — not shown to students once collapsed; remove before publishing.
What you’ll get from this sheet
The workhorse for comparing two means — and why it doesn’t scale to many groups. By the end you should be able to:
- Pick the right t‑test (one‑sample, independent, paired) and read the t‑formula.
- Choose one‑ vs two‑tailed, and count pairwise comparisons with \(k(k-1)/2\).
A t‑test compares means by scaling the difference by its variability: \(t = \dfrac{\text{difference}}{\text{standard error}}\). Big difference or small variance → big t. Three flavours: one‑sample (mean vs a known value), independent (two unrelated groups), paired (two related scores). Comparing many groups needs \(k(k-1)/2\) t‑tests — which inflates family‑wise error.
NoteDid you know? The t-test was born in a brewery
The t-test was devised in 1908 by William Sealy Gosset, a chemist at the Guinness brewery in Dublin, who needed to draw conclusions from the small samples of an industrial process — barley varieties, yeast counts. Guinness treated statistical know-how as a trade secret and forbade employees from publishing, so Gosset wrote under the pseudonym “Student”, which is why we still call it Student’s t-distribution. Its heavier tails are precisely his correction for the extra uncertainty of small samples.
The three t-tests
All three ask “do these means differ?”, differing only in the design:
- One‑sample — compare a sample mean to a known value (is mean IQ different from 100?).
- Independent‑samples — compare two unrelated groups (danceability of 2000s vs 1990s songs).
- Paired‑samples — compare two related scores (the same people, pre vs post).
The engine is the same in each: the t‑statistic scales the difference in means by the variability. By hand, a large difference in means — or small variances — produces a large t, which infers a real difference; a small difference or large variances produces a small t, inferring none. It’s the signal‑to‑noise idea again: \(t = \text{signal} \div \text{noise}\).
Big difference or small noise → big t
Two decades of danceability. Slide the difference in their means and watch t and its p‑value respond; switch between a one‑ and two‑tailed test:
At zero difference the means sit atop each other and t ≈ 0. Widen the gap (or, equivalently, shrink the noise) and t grows until it clears the critical value and the result turns significant. Flip to one‑tailed and the same t reaches significance sooner — because a one‑tailed test spends all of α (.05) in a single tail, testing only one direction (“2000s more danceable”), whereas a two‑tailed test splits α across both tails and is more conservative (testing for any difference).
One- or two-tailed? Decide before you look
A two-tailed test asks “is there any difference?” and splits α across both tails (±1.96 at α = .05). A one-tailed test asks a directional question (“is B greater than A?”), putting all of α in one tail (1.645), so it reaches significance more easily — but it is blind to an effect in the opposite direction. The non-negotiable rule: choose the direction before you see the data. Switching to one-tailed after peeking, because it drags you under .05, is a form of p-hacking. Reserve one-tailed tests for cases where a result in the other direction would be genuinely uninteresting or impossible.
NoteQuiz
Answer each question — the feedback appears beneath it.
Assumptions — and how robust the t-test is
The t-test rests on three assumptions:
- Independence of observations — each measurement is separate and uninfluenced by the others. This is the critical one: violate it (e.g. analysing repeated measures as if they were independent) and the test is simply wrong. The paired test is the designed-in way to handle dependence, by analysing the differences.
- Normality — of the underlying data, or more precisely of the sampling distribution of the mean.
- Equal variances — for the independent t-test, the two groups are assumed to have similar spread. When they don’t, use Welch’s t-test (the default in R’s
t.test()), which adjusts the degrees of freedom.
The reassuring part is robustness: thanks to the CLT, the t-test tolerates non-normality well once samples are reasonably large (roughly n ≳ 30 per group), because it’s the mean’s distribution that needs to be normal, not the raw data. The danger zone is small samples of clearly non-normal data — there, consider a transformation or a non-parametric alternative (Mann–Whitney / Wilcoxon).
Which t-test? Quick quiz
Match each scenario to the right t-test:
NoteQuiz
Answer each question — the feedback appears beneath it.
Why it doesn’t scale: pairwise comparisons
A t‑test compares two groups. To compare more, you’d need every pair — and the count grows fast:
\[\text{number of comparisons} = \frac{k(k-1)}{2}\]
So 3 groups → 3 tests, 4 → 6, and 6 groups → 15. Each test carries its own 1‑in‑20 chance of a false positive at α = .05, and those chances accumulate — much like rolling a die ten times gives roughly an 84% chance of at least one six. That runaway family‑wise error is why we don’t just spray t‑tests at a multi‑group design; we use ANOVA (one omnibus test) and, if needed, corrected post‑hoc comparisons.
See it in code
[h, p, ci, stats] = ttest2(d00, d90); % independent-samples t-test
% [h,p] = ttest(x, 50); % one-sample
% [h,p] = ttest(pre, post); % pairedThe R and Python tabs run live; MATLAB is a static reference.
TipCheck your understanding
You compare two groups and get t = 0.4, p = .69, even though their means differ by a few points. Why isn’t it significant — and would a one‑tailed test have saved it?
Because t is the difference relative to its standard error: a few points of difference against large within‑group variability (or a small sample) gives a small t. The signal is swamped by noise. A one‑tailed test would only help modestly (it lowers the threshold from ~1.96 to ~1.64), and only if the difference is in the predicted direction — it can’t rescue a t of 0.4. The real fix is more data or less noise, not a friendlier tail.
Decide one‑ vs two‑tailed before you see the data — picking a one‑tailed test after peeking, because it nudges you under .05, is a form of p‑hacking. A one‑tailed test also can’t detect an effect in the opposite direction, so use it only when a reversal would be uninteresting or impossible. And never answer a many‑group question with a pile of t‑tests — the \(k(k-1)/2\) comparisons inflate family‑wise error; use ANOVA instead.
Where this shows up next
The pairwise‑comparison explosion motivates Family‑Wise Error and ANOVA (one test for many groups). And the independent t‑test is just a two‑group general linear model. See Chapter (Inference).