← Lessons

quiz vs the machine

Gold1390

Machine Learning

The T Test

Comparing means when the sample is small or variance unknown.

4 min read · core · beat Gold to climb

The T Test

The t test decides whether the means of groups differ more than random chance would explain. It is the workhorse when comparing averages with realistic sample sizes.

Why not a z test

A z test assumes you know the true population standard deviation. In practice you only have a sample estimate, which adds uncertainty. The t test uses the t distribution, a bell curve with heavier tails that widen for small samples, properly accounting for that extra uncertainty.

Common forms

  • A one sample t test checks whether a sample mean differs from a known target.
  • A two sample t test compares the means of two independent groups.
  • A paired t test compares two measurements on the same subjects, like before and after.

Degrees of freedom

The shape of the t distribution depends on the degrees of freedom, roughly the sample size minus the number of estimated means. As degrees of freedom grow, the t distribution approaches the normal, which is why large samples let a z test substitute.

Reading the result

The test produces a t statistic and a p value. A small p value says the observed difference in means is unlikely under the null of equal means.

Key idea

The t test compares means using a sample based standard error and the heavier tailed t distribution, making it valid for small samples with unknown variance.

Check yourself

Answer to earn rating on the learn ladder.

1. When is a t test preferred over a z test?

2. What kind of t test compares before and after measurements on the same subjects?

3. As degrees of freedom grow, the t distribution approaches what?