When to Use a T-Test vs. Z-Test: Key Differences

Use a z-test when you know the population standard deviation and have a large sample (30 or more). Use a t-test when you don’t know the population standard deviation and are estimating it from your sample, which is the case in the vast majority of real-world research. That single distinction, whether or not you know the true population spread, is the primary decision point.

The Core Distinction: Known vs. Unknown Variance

The fundamental difference comes down to one question: do you know the standard deviation of the entire population you’re studying? If yes, you can use a z-test. If no, you need a t-test.

In practice, you almost never know the population standard deviation. Think about it: if you already knew enough about the population to have its exact variability measured, you’d probably already know its mean too, which would make hypothesis testing unnecessary. Penn State’s statistics program acknowledges this directly, calling it “completely unrealistic” to know the population variance but not the population mean. That’s why the t-test dominates real research. The z-test is mostly a teaching tool that introduces the logic of hypothesis testing before adding the extra uncertainty that comes with estimating variance from a sample.

Why Sample Size Matters

You’ll often see “30” cited as the dividing line between small and large samples. This comes from the central limit theorem: once your sample hits about 30 observations, the sampling distribution of the mean closely approximates a normal (bell-shaped) curve regardless of how the underlying data is distributed. At that point, even if you’re using the sample’s own variance (which technically calls for a t-test), the t-distribution and the normal distribution are nearly identical, so the z-test and t-test give you essentially the same answer.

This is because the t-distribution’s shape depends on degrees of freedom, calculated as your sample size minus one. With 10 observations, the t-distribution has heavier tails than the normal curve, meaning it accounts for the extra uncertainty of estimating variance from limited data. With 100 observations, those tails slim down and the t-distribution becomes virtually indistinguishable from the normal distribution. So while using a t-test with a large sample is never wrong, it stops making a practical difference once your sample is large enough.

When to Use a Z-Test

Z-tests fit a narrow set of conditions: you have a large sample (30 or more), you know the population standard deviation, and your data follows a normal distribution. The most common real scenario is comparing a sample mean to a known population benchmark. For example, if a standardized test has a published national mean and standard deviation, and you want to know whether your class of 40 students performed differently from the national average, a z-test applies because the population parameters are already established.

Z-tests also appear in proportion testing. If you’re comparing the proportion of customers who clicked a button to a known baseline rate and your sample is large, you’re working with a z-test for proportions. In these cases the population variance can be derived directly from the proportion itself, so the “known variance” requirement is automatically met.

When to Use a T-Test

T-tests cover almost everything else. Any time you’re collecting your own data and calculating both the mean and the standard deviation from that sample, you’re in t-test territory. This includes three common scenarios:

  • One-sample t-test: Comparing your sample mean to a hypothesized value when you don’t know the population standard deviation. For instance, testing whether patients taking a new sleep medication sleep more hours than a target threshold, using only the data you collected from the trial.
  • Independent two-sample t-test: Comparing the means of two separate groups, like a treatment group versus a control group.
  • Paired t-test: Comparing measurements from the same group at two different times, like blood pressure before and after an intervention.

The t-test assumes your data is roughly normally distributed, that observations are independent of each other, and that the data is measured on a continuous scale. For the two-sample version, there’s an additional assumption that the two groups have similar variance (called homogeneity of variance).

Student’s T-Test vs. Welch’s T-Test

If you’re comparing two groups and suspect their variances aren’t equal, Welch’s t-test is the safer choice. The standard (Student’s) t-test assumes both groups have the same spread. Welch’s version adjusts the degrees of freedom to account for unequal variances and handles unequal sample sizes more reliably. Many statisticians recommend defaulting to Welch’s t-test for two-sample comparisons because it performs well even when variances happen to be equal, giving you a correct answer either way.

Quick Decision Framework

When you’re choosing between these tests, walk through three questions in order:

  • Do you know the population standard deviation? If yes, and your sample is large, use a z-test. If no, use a t-test.
  • Is your sample smaller than 30? Use a t-test. The heavier tails of the t-distribution protect you from the added uncertainty of a small sample.
  • Is your sample 30 or larger, but you still estimated variance from the data? A t-test is still technically correct, though the results will be nearly identical to a z-test.

The key takeaway is that the t-test is almost always the right default. It handles the uncertainty of estimated variance, works with any sample size, and converges to the same result as a z-test when samples get large. The z-test is best understood as a special case you’ll encounter in textbooks and in the rare situation where true population parameters are available.

Common Mistakes to Avoid

The most frequent error is choosing a z-test simply because the sample is large. Sample size alone isn’t enough. If you calculated the standard deviation from your data rather than looking it up from a known population parameter, you should still use a t-test, even with 500 observations. You’ll get nearly the same p-value either way, but the t-test is the technically correct choice.

Another common mistake is ignoring the normality assumption with small samples. Both tests assume the data (or more precisely, the sampling distribution of the mean) is approximately normal. With large samples, the central limit theorem handles this for you. With small samples, it doesn’t. If your data is heavily skewed and you have fewer than 30 observations, neither a z-test nor a standard t-test may be appropriate, and a nonparametric alternative could be a better fit.