When do you use a paired t-test instead of an independent t-test?
Use a paired t-test when the two measurements come from the same subjects or matched pairs, such as before and after. It tests whether the mean of the differences is zero, which removes person-to-person variation.
Explain it simply
If you measure the same five students before and after a coaching course, each student is their own control. A weak student stays weak in both measurements. Comparing the two columns as independent groups throws away that link and adds noise. The paired test looks at each student's change instead.
Example
Scores before and after:
- Before: 60, 62, 65, 70, 68
- After: 63, 66, 66, 74, 71
- Differences: 3, 4, 1, 4, 3 (mean 3.0)
from scipy import stats
before = [60, 62, 65, 70, 68]
after = [63, 66, 66, 74, 71]
t, p = stats.ttest_rel(after, before)
print(round(t, 2), round(p, 4)) # 5.48 0.0054The paired test gives t = 5.48 and p = 0.0054. Treating them as independent groups gives a much smaller t, since the spread between students hides the consistent improvement of about 3 marks.
What to say in the interview
"Paired when observations are naturally linked: before and after on the same users, matched pairs, or two methods on the same samples. It is equivalent to a one-sample t-test on the differences. Independent is for separate groups. Choosing paired for unrelated groups, or independent for linked data, gives wrong answers."
Common mistakes
- Pairing rows just because they share an index position when there is no real link between them.