Skip to content

t-tests: one-sample and two-sample

6 min read

Short answer

When the population standard deviation is unknown, replace σ\sigma by the sample ss and use the tt distribution with n−1n-1 degrees of freedom: t=xˉ−μ0s/nt=\dfrac{\bar x-\mu_0}{s/\sqrt n}. For two groups, t=xˉ1−xˉ2s12/n1+s22/n2t=\dfrac{\bar x_1-\bar x_2}{\sqrt{s_1^2/n_1+s_2^2/n_2}} (Welch).

One-sample t compared with Two-sample (Welch) tOne-sample tCompare a mean with atarget μ₀t = (x̄ − μ₀) / (s/√n)df = n − 1Two-sample (Welch) tCompare two groupmeansSE = √(s₁²/n₁ +s₂²/n₂)Does not assume equalvariances
Same idea: difference divided by its standard error.

Why t instead of z

Estimating σ\sigma by ss adds uncertainty, so the statistic has heavier tails than a normal. The tt distribution captures that, with the effect fading as nn grows: at 30 degrees of freedom it is already close to normal.

Assumptions

The data should be roughly normal, or the sample large enough for the central limit theorem to help; observations must be independent. For two samples, the groups are independent unless the data are paired, in which case test the differences with a one-sample tt.

Worked example

A sample of n=16n=16 has xˉ=52\bar x=52 and s=8s=8. Test H0:μ=48H_0:\mu=48 against H1:μ≠48H_1:\mu\ne48 at 5%.

SE=8/16=2\text{SE}=8/\sqrt{16}=2, so t=52−482=2.0t=\dfrac{52-48}{2}=2.0 with 1515 degrees of freedom. The two-sided critical value is 2.1312.131. Since 2.0<2.1312.0<2.131, fail to reject H0H_0 (p≈0.064p\approx0.064).

Try it yourself

Which t-test fits blood pressure measured on the same 20 patients before and after a drug?

Show the answer

A paired test: compute the 20 differences and run a one-sample tt-test of the mean difference against 00, with 1919 degrees of freedom.

Keep going with practice

Vidi's variance and standard deviation lessons are the groundwork for the s in every t statistic.