Calculators
Home › Learn › t-Test vs z-Test

When to Use a t-Test vs a z-Test

One question decides it: is sigma known from outside the sample?

Quick answer: Sigma known: z is available. Sigma estimated: t, at any n. Same bakery data: t gives p = 0.0316; z with a truly known sigma of 6 gives 0.0339.

The whole decision in one question

Do you know the population standard deviation σ from outside your sample? If yes, the z-test is available: its standard error σ/√n is exact, and the normal distribution gives the p-value. If no, and in practice it is almost always no, the t-test is the correct procedure: s estimates σ, and the t distribution's heavier tails price that estimation honestly. That single question settles most cases; everything else is refinement.

Same data, both tests

The bakery's eight days: x̄ = 44.5, s = 4.751, testing against 40. As a t-test: t = 2.679, df 7, p = 0.0316. Pretend instead that σ = 6 is genuinely known from years of records: the standard error becomes 6 ÷ √8 = 2.121, z = 2.121, p = 0.0339. Close here, because the gap between s and σ is modest. At small samples with a lucky small s, the z machinery would claim far more confidence than the data earned; the t tails are the correction for exactly that.

The large-sample middle ground

As n grows, the t distribution converges to the normal (at df 30 they are hard to tell apart; at df 120, effectively identical) and s converges to σ, so the two tests merge. This is the honest root of the "n > 30" folklore: not a rule that t becomes wrong or z becomes right, but the point where the difference stops mattering for most decisions. Proportions work differently again: proportion tests use z machinery built on the null's p0 or a pooled estimate, at any n where the counts support the approximation. When the outcome is a proportion, neither of the mean tests applies.

Watch out

Using a previous study's sample SD as if it were a known σ. An estimate with its own sampling error is not knowledge; feeding it into a z-test imports the earlier noise as if it were fact. Only a σ fixed by the measurement process itself (a calibrated instrument's known precision) qualifies.

Frequently asked questions

What is the main difference between the t-test and z-test?

The standard error's denominator: z uses a known population sigma, t uses the sample SD and pays for the estimation with heavier tails and degrees of freedom.

Is the z-test ever right for means in practice?

Rarely: when sigma is fixed by the instrument or process itself. Quality control with a calibrated gauge is the standard example. Research data almost always calls for t.

At what sample size can I stop worrying about the choice?

Around n = 30 to 50 the two answers sit close together for typical data, and they coincide as n grows. The t-test stays valid throughout, so choosing it always is a safe habit.