Z-Test vs t-Test: When to Use Each

A z-test and a t-test ask one question β€” is this mean different from expected? β€” but they assume different things. The z-test needs the population standard deviation; the t-test estimates it from the sample. This guide gives the decision rule, runs the data both ways, and shows how the t-curve collapses onto the normal curve as samples grow.

The short version: use a z-test only when you know the population standard deviation Οƒ. In almost every real analysis you do not know Οƒ, so you estimate it from the sample β€” and the moment you do that, you are running a t-test, whether you call it one or not.

That one distinction drives everything else in this guide. We define both tests, state the decision rule in a single sentence, run the same 36 observations through both tests so you can see the p-values move, show the t-curve collapsing onto the normal curve as the sample grows, and finish with a three-question tool that tells you which test to use. The worked examples use the same data both ways, so the only thing that changes is the distribution you compare against.

What is a z-test?

A z-test compares a sample mean with a claimed value, using the standard normal distribution. It asks: if the true mean really were ΞΌβ‚€, how surprising would this sample mean be? The test statistic is z = (xΜ„ βˆ’ ΞΌβ‚€) / (Οƒ / √n), where xΜ„ is the sample mean, ΞΌβ‚€ is the value you are testing against, Οƒ is the population standard deviation, and n is the sample size. The denominator, Οƒ / √n, is the standard error of the mean β€” the typical distance between a sample mean and the true mean.

A z-test is valid only when Οƒ is known. That is the whole condition, and it is a strong one: in practice Οƒ is almost never known. The classic cases where it is known are a manufacturing process whose Οƒ has been established over years of production, and a standardised test whose population Οƒ is published. Outside those cases, the z-test does not apply β€” and that is why the t-test exists.

When the conditions hold, the z-statistic follows the standard normal distribution, the bell curve with mean 0 and standard deviation 1. For a two-tailed test at Ξ± = 0.05 the critical value is 1.96: a |z| beyond 1.96 is significant. The p-value comes from the normal curve β€” in Excel, =2*(1-NORM.S.DIST(ABS(z),TRUE)) gives the two-tailed p-value. Our normal distribution calculator draws the curve and shades the tail, and the p-value calculator from z-score turns any z into a p-value.

Because Οƒ is treated as a fixed, known number, the z-test has no extra uncertainty to account for. That is what makes it exact β€” and what makes it so rarely usable.

What is a t-test?

A t-test does the same job as a z-test β€” it compares a sample mean with a claimed value β€” but it does not pretend to know Οƒ. Instead it estimates Οƒ from the sample itself, using the sample standard deviation s. The test statistic is t = (xΜ„ βˆ’ ΞΌβ‚€) / (s / √n), which looks identical to the z formula except that s stands where Οƒ stood. That one substitution changes the distribution you compare against: the statistic now follows Student’s t-distribution, not the normal curve.

The t-distribution is the normal curve with heavier tails, and the extra tail weight is the price of estimating Οƒ. When s underestimates Οƒ β€” which happens in about half of all samples β€” the t-statistic is inflated, so extreme values occur more often than the normal curve would predict. The t-distribution accounts for exactly that. Its shape depends on the degrees of freedom, df = n βˆ’ 1: with few observations the tails are very heavy (at df = 1 the 97.5% critical value is 12.71, not 1.96); as n grows the tails thin and the curve settles onto the normal.

That is why the t-test is the workhorse of real data analysis. You almost never know Οƒ, so you almost always use the t-test: the one-sample t-test for a single mean, the two-sample t-test for two independent groups, and the paired t-test for before-and-after measurements on the same subjects. Our one-sample t-test calculator runs the test and draws the t-curve with your statistic marked, and the t-distribution calculator looks up any area, p-value or critical t for any degrees of freedom.

One caution: the t-test fixes the Οƒ problem, not the normality problem. For small samples the data should still be roughly normal β€” the t-distribution assumes the underlying observations are normal. With a large sample the central limit theorem covers moderate skew, but a small, heavily skewed sample needs a different approach, not a t-test.

The one question that decides: is Οƒ known?

Strip away the formulas and the choice between a z-test and a t-test comes down to one question: do you know the population standard deviation Οƒ? If you do, use a z-test. If you do not β€” and in real work you almost never do β€” use a t-test. Everything else (sample size, tail shape, critical values) follows from that answer.

Use a z-test only when the population standard deviation Οƒ is known (rare in practice) or when n is so large that s β‰ˆ Οƒ. Using s in place of Οƒ and calling it a z-test is WRONG β€” that is a t-test. The distinction is not pedantry: the moment you plug the sample standard deviation s into the formula, the statistic stops following the normal curve and starts following the t-distribution, because s itself varies from sample to sample. A z-test that uses s is a t-test wearing the wrong label, and its p-value is too small.

Genuinely known Οƒ is rare. It happens when a process has been measured so often that its spread is a settled fact β€” a production line whose Οƒ has been tracked for years, or a standardised test whose population parameters are published. If you are working from a single sample, or from data you collected yourself, Οƒ is not known: estimate it with s and run a t-test.

Sample size does not change the rule. A large n makes the t-test and the z-test give nearly the same answer, but it does not turn a t-test into a z-test. The decision table is short:

SituationTest to use
Οƒ known (and data roughly normal, or n large)z-test
Οƒ unknown β€” estimate it with st-test (any n)
Οƒ unknown, small n, skewed dataNeither yet β€” check normality first

This guide does not re-teach the five steps of a hypothesis test β€” setting up Hβ‚€ and H₁, choosing Ξ±, computing the statistic, finding the p-value and deciding. They are the same for both tests; only the distribution changes. If you need them, our hypothesis testing explained guide works them through with z, t and chi-square examples. The definitions here follow the NIST/SEMATECH e-Handbook, 1.3.5.2. Confidence Limits for the Mean.

The same data, both ways

Here is the cleanest way to see the difference: take one dataset and run it through both tests. A class of 36 students takes a test whose national mean is 100. Their mean is 105 and their standard deviation is 12. The question is the same either way β€” is 105 genuinely above 100, or could a sample mean this high arise by chance from a population whose mean is 100?

First the standard error: SE = s / √n = 12 / √36 = 12 / 6 = 2.00. Then the statistic: (xΜ„ βˆ’ ΞΌβ‚€) / SE = (105 βˆ’ 100) / 2.00 = 2.50. So far the two tests agree completely β€” the number 2.50 is the same whether you call it z or t. What differs is the distribution you compare it against.

TestStatisticdfTwo-tailed pOne-tailed pVerdict at Ξ± = 0.05
z-test2.50β€”0.012420.00621Reject Hβ‚€
t-test2.50350.017260.00863Reject Hβ‚€

Both tests reject Hβ‚€ at Ξ± = 0.05, so the conclusion is the same here. But the p-values are not: the z-test’s two-tailed p is 0.01242 while the t-test’s is 0.01726 β€” about 39% larger. The z-test’s p is smaller because it treats s = 12 as if it were the true Οƒ, ignoring the uncertainty in that estimate. The t-test (df = 35) charges for that uncertainty with heavier tails, so the same statistic looks less surprising.

In Excel, the z p-value is =2*(1-NORM.S.DIST(2.5,TRUE)) and the t p-value is =T.DIST.2T(2.5,35); the one-tailed versions are =1-NORM.S.DIST(2.5,TRUE) and =T.DIST.RT(2.5,35). You can check both on this site: the p-value calculator from z-score turns 2.50 into 0.01242, and the one-sample t-test calculator gives the t result with the curve drawn.

The lesson: when the two tests disagree, trust the t-test. It is the one that admits what you do not know.

How the t-curve becomes the normal curve

As the degrees of freedom grow, the t-distribution’s tails thin and the curve settles onto the standard normal. The reason is simple: with more data, s becomes a better estimate of Οƒ, so the extra uncertainty that fattens the tails shrinks away. By df = 30 the two curves are already hard to tell apart, and by df = 100 they agree to two decimal places.

Degrees of freedom97.5% critical value (t*)
df = 112.7062
df = 52.5706
df = 102.2281
df = 302.0423
df = 1001.9840
z (normal)1.9600

The table is the convergence in numbers. At df = 1 the critical value is 12.7062 β€” more than six times the normal 1.9600 β€” because with one degree of freedom s is almost pure noise. At df = 5 it has fallen to 2.5706, at df = 30 to 2.0423 (only 4% above 1.96), and at df = 100 to 1.9840, within 1.2% of 1.96. These are the critical values from the NIST/SEMATECH e-Handbook, 1.3.6.7.2. Critical Values of the Student’s-t Distribution; you can look up any df on our t-distribution calculator, or in Excel with =T.INV.2T(0.05,df) for t* and =NORM.S.INV(0.975) for 1.96.
Here is the same story with real numbers. Take n = 100, xΜ„ = 102, s = 15, ΞΌβ‚€ = 100. The standard error is 15 / √100 = 1.50, so the statistic is (102 βˆ’ 100) / 1.50 = 1.3333 with df = 99. The t-test gives a two-tailed p of 0.1855; the z-test gives 0.1824. The two p-values differ by 0.0031 β€” nothing. With 100 observations the choice of distribution barely matters, which is exactly what the table predicts. But note the direction: the t-test is still the correct test when Οƒ is unknown. Large n makes the two answers agree; it does not make the z-test right. If you need a critical value for any confidence level, our how to find a critical value guide shows z* and t* by hand and on the TI-84.

How the t-curve collapses onto the normal curve

βˆ’4 βˆ’3 βˆ’2 βˆ’1 0 1 2 3 4 0 0.1 0.2 0.3 0.4 z* = 1.96 t(5)* = 2.57

β€” t, df = 1   β€” t, df = 5   β€” t, df = 30   – – Normal (z)

97.5% critical values: z = 1.9600 · t(30) = 2.0423 · t(5) = 2.5706 · t(1) = 12.7062 (off the chart)

The t-distribution with 1 degree of freedom (red) is wide and flat; by df = 30 (blue) it is almost indistinguishable from the standard normal curve (navy, dashed).

The n β‰₯ 30 rule β€” and why it is not a law

You will meet a rule of thumb in many textbooks: if n β‰₯ 30, use a z-test. It is a shortcut from the days before computers, when looking up t-values in a printed table was tedious and the normal table was the easy one. The reasoning was that by n = 30 the t-curve is close enough to the normal curve that the answers barely differ β€” and as the table above shows, that part is true: at df = 30 the critical value is 2.0423, only 4% above 1.96.

But the rule is not a law, and it does not say what people think it says. It is a statement about the shape of the t-curve, not about Οƒ. Even at n = 1,000, if Οƒ is unknown, the correct test is still the t-test β€” it is just that the t and z answers are numerically almost identical by then. The β€œn β‰₯ 30 means z-test” teaching confuses β€œthe two tests agree” with β€œuse the z-test”. They are not the same claim. There is no sample size at which plugging s into the z formula becomes correct; there is only a sample size at which the error becomes too small to matter. Today there is no reason to take the shortcut: software and calculators give you the t-test instantly, so use the test that matches what you actually know.

So treat n β‰₯ 30 as a reassurance, not a licence: it tells you that if you ran the z-test by mistake, the answer would be close β€” not that you should run it.

Common mistakes

1. Using s in place of Οƒ and calling it a z-test. This is the big one, and it is the mistake this whole guide exists to prevent. The moment s enters the formula, the statistic follows the t-distribution. Call it a t-test, because that is what it is β€” and because the p-value from the normal curve will be too small.

2. Choosing z because n is large. A large n makes the t-test and the z-test agree, but it does not turn a t-test into a z-test. The test is decided by whether Οƒ is known, not by how many observations you have. If Οƒ is unknown, run the t-test at any n β€” the large sample just means the answer will be close to the z answer.

3. Using a t-test when Οƒ is known. The reverse error is rarer but real: when Οƒ genuinely is known and n is small, the z-test is exact and the t-test is conservative β€” wider intervals and larger p-values than necessary. If you know Οƒ, use it. Do not reach for the t-test out of habit.

4. Forgetting the normality assumption. Both tests assume the underlying data are roughly normal when n is small. The t-test fixes the Οƒ problem; it does not fix skewed data. With a small, heavily skewed sample, neither test is safe β€” consider a transformation, or a non-parametric alternative. And remember that a p-value is not the probability that the null hypothesis is true; our what is a p-value guide explains what it actually means.

Decision tool: three questions

Answer these three questions in order and you will land on the right test.

  1. Do you know the population standard deviation Οƒ? If yes, use a z-test (provided the data are roughly normal or n is large). If no, go to question 2.
  2. Are you estimating Οƒ from the sample (s)? Then you are running a t-test β€” at any sample size. Go to question 3 to check the remaining assumption.
  3. Are the data roughly normal, or is n large enough for the central limit theorem? If yes, run the t-test. If no β€” small n and clearly skewed data β€” neither test is safe yet: check normality, transform, or use a non-parametric test.

In short: Οƒ known β†’ z-test. Οƒ unknown β†’ t-test. That is the whole decision.

Frequently Asked Questions

Can I use a z-test if n is large but Οƒ is unknown?

Strictly, no β€” the correct test is the t-test, because you are estimating Οƒ with s. In practice the difference is negligible: with a large n the t-distribution is almost normal, so the two p-values agree to two or three decimal places. Use the t-test and call it a t-test; the large sample is a reassurance, not a licence to relabel it.

What if n is small and Οƒ is known?

Use the z-test. That is the one case where it is exact and the t-test would be conservative β€” wider intervals and larger p-values than necessary. Small n is fine for a z-test as long as the data are roughly normal (or the population is known to be normal). The z-test’s weakness is unknown Οƒ, not small n.

Does the t-test need normal data?

For small samples, yes β€” roughly normal. The t-distribution assumes the underlying observations are normal, and with few observations there is not enough data for the central limit theorem to help. With a large sample, moderate skew is fine. The t-test fixes the Οƒ problem, not the normality problem.

Is the z-test ever better than the t-test?

Yes β€” when Οƒ is genuinely known. Then the z-test is exact and slightly more powerful: narrower confidence intervals and smaller p-values for the same data. But Οƒ is almost never known in practice, so the advantage is mostly theoretical. The one place z-tests genuinely shine is proportions, where the standard error is determined by the null value rather than estimated from a sample.

Why does the t-distribution have heavier tails?

Because s is estimated from the same sample. When s happens to underestimate Οƒ β€” which it does in about half of all samples β€” the t-statistic is inflated, so extreme values occur more often than the normal curve predicts. The t-distribution builds that extra spread in. As n grows, s stabilises, the extra spread vanishes, and the tails thin down to the normal curve.

What is the n β‰₯ 30 rule really?

A rule of thumb that by about 30 degrees of freedom the t-curve is close enough to the normal curve that the two tests give similar answers. It is not a rule that n β‰₯ 30 licences a z-test when Οƒ is unknown. The correct test is still the t-test; the answers just agree. It dates from the era of printed tables, when the normal table was easier to use than the t-table.

Can I use a z-test for proportions?

Yes β€” the one-proportion and two-proportion z-tests are genuine z-tests. They use the normal approximation to the binomial, and their standard error is computed from the proportions (and the null value), not from a sample standard deviation β€” so there is no estimated Οƒ to account for. Our two-proportion z-test calculator runs the pooled test with Cohen’s h and a confidence interval.

Check Tools

Try the numbers from this guide with the site’s free calculators:
T-Distribution Calculator
Look up any area, p-value or critical t for any degrees of freedom.
Try the T-distribution calculator β†’
One-Sample T-Test Calculator
Test one mean against a claimed value with the t-distribution.
Try the one-sample t-test calculator β†’
P-Value Calculator from Z-Score
Turn any z-score into a one- or two-tailed p-value.
Try the p-value calculator from z-score β†’
Explore All Statistical Tools
See every calculator on the site in one place.
Browse all our statistical tools β†’

Check Articles

Go deeper with these guides:
Hypothesis Testing Explained
The five steps of a hypothesis test, with worked z, t and chi-square examples.
Read the guide β†’
T-Distribution vs Normal Distribution
How the t-curve differs from the normal curve β€” and when they agree.
Read the guide β†’
What Is a P-Value?
What a p-value really means β€” and what it does not.
Read the guide β†’
How to Find a Critical Value
Find z* and t* for any confidence level, by hand and on the TI-84.
Read the guide β†’