# Why is a t-test necessary given that we have the z-test?

Can someone give an explanation for why the t-test "happens"? I was taught to use the t-test when you don't know the population standard deviation (i.e., you only know the standard deviation of your sample), but I'm not sure why that would make it different from a z-test.

• I've updated your title to get at the question I think you are asking; feel free to edit if I have misconstrued Sep 30, 2011 at 6:58

I don't think I understand your question completely. Are you asking why you would use a t-test?

If you understand why you would use a z-test, you should have a good idea of why you would use a t-test. For large samples, a z-test and a t-test should render similar or identical results. But while a z-test will assume a normal distribution, a t-test will take into account uncertainty in sample distribution at smaller samples sizes.

• Hmm the t-test also assumes a normal distribution. Perhaps what you meant to say is that we require less information about that distribution. Sep 8, 2014 at 12:11
• @JohnK I don't think it makes sense saying a test assumes a distribution in the first place, but I think Benjamin meant that the t-score/statistic assumes the T-distribution and not the Z-distribution. Aug 8, 2015 at 0:33

The z-test itself is actually a likelihood ratio test between the likelihood assuming the null hypothesis and the likelihood assuming the alternate hypothesis. Assuming underlying normal distributions with known variances and only testing the means, the algebra simplifies to the z-test we know and love (DeGroot 1986, pp. 442–447).

Using the same maximum likelihood procedure, but treating the variance as an unknown, creates a different pair of likelihoods and their ratio, and letting the algebra simplify out gives the statistic: $$\frac{\sqrt{n}\left(\bar{X}_n - \mu_0\right)}{\sqrt{\frac{S^2_n}{n-1}}}$$ (DeGroot 1986, pp. 485–489). The testing distribution in question changes as well, as the numerator of the above statistic is normally distributed, $\bar{X}$, and the denominator is distributed as square root of squared normals, the $S^2$, which is the square root of a chi-square random variable. Gosset (Student) showed that if you have a random variable: $$Y \sim N(0, 1)\\ Z \sim \chi^2_n\\ X \sim \frac{Y}{\sqrt{\frac{Z}{n}}}$$ then X is distributed with the t distribution and n degrees of freedom.

So, to state it without rigor, the t-test is the natural outcome of the same likelihood ratio process that is behind the z-test when the variance of the data is itself unknown and is being estimated through maximum likelihood.

• this was very enlightening. I had completely forgotten that the t-test comes from maximum likelihoood Apr 16, 2015 at 16:19

The non-rigorous answer is that you want to use a t-test when you have a small number of samples because of the chance that the samples are unusually close together (relative to the actual population variance). In that case, the denominator in the formula for the t-statistic will be unusually small, and so the t-statistic itself will be unusually large. Thus, you're much more likely to get a large value for the t-stat when you have a small number of samples than you would be to get a comparably large z-stat, so you need a larger value to reject the null using the t-test than the z-test at the same significance level.

• I find the argument appealing but, upon reflection, unconvincing. After all, if by chance the samples are unusually far apart (which ought to happen just as easily as being unusually close), then it seems the very same logic would lead to the opposite conclusion.
– whuber
Sep 8, 2014 at 15:06

The most important differentiator is sample size, as a rule of thumb: If $n$ is smaller than $30$ a t-test should be used, otherwise a z-test.

A good overview of the underlying assumptions and differences (and similarities) of both tests is given here:
http://www.le.ac.uk/bl/gat/virtualfc/Stats/ttest.html