# Having a problem getting the Intuition behind t-tests and z-tests

Say we have a population of $$n$$ rodents and that the mean of the population is $$\mu$$ with standard deviation $$\sigma$$, the standard error of means in this population would be $$\frac{\sigma}{\sqrt n}$$ .

Now if we have a sample with mean $$\bar{x}$$ and we apply the z-test $$Z=\frac{\bar{x}-\mu}{\frac{\sigma}{\sqrt n}}$$

What exactly does this test statistic represent?

Is it a measure of how far away the sample mean is from the acceptable spread of the population means?

And would the reasoning that;

As long as the mean of the sample $$\bar{x}$$ shown by the green line is within the white area, it does not deviate more than the standard error of means in the population and hence is an acceptable distance away from the actual population mean $$\mu$$ which is the blue line.

presented by this graph of the weight distributions in the sample be valid?

• What is that vertical "N" line?
– Dave
Commented Feb 24, 2021 at 20:35
• Pardon my bad handwriting that is meant to show the value of weight the actual population mean $\mu$ would be at Commented Feb 24, 2021 at 20:36
• So it's supposed to be $\mu$? Gotcha. Consider clarifying that in the post.
– Dave
Commented Feb 24, 2021 at 20:37

The Z-test is a hypothesis test. There are few assumptions:

• Z-test need to have at least 30 or more random samples
• Z-test needs to have alpha (null hypothesis)
• Needs Z-score (alternative hypotheses)

The 1st requirement is because we use CLT to conduct the mean of the distribution from the samples $$\bar{x}$$.

Now the formula $$Z=\frac{\bar{x}-\mu}{\frac{\sigma}{\sqrt n}}$$ has a super meaning:

Z-score is 0, it indicates that the data point's score is identical to the mean score. A Z-score of 1.0 would indicate a value that is one standard deviation from the mean. Z-scores may be positive or negative, with a positive value indicating the score is above the mean and a negative score indicating it is below the mean.

Here's the problem the z/t value is supposed to help solve and an intuitive explanation how it does it. I'm going to gloss over a lot of extra complexities to try and keep things simple.

You drew a SAMPLE of $$n$$ rodents from a larger population of some large size (it doesn't matter how big the population itself is). Within this sample you estimate the mean of some value as $$\bar{x}$$ with a standard deviation of $$\sigma$$. You want to know if this estimate $$\bar{x}$$ is different from some known value $$\mu$$.

$$\bar{x}$$ and $$\mu$$ LOOK different but maybe, because you only only drew a sample of $$n$$ rodents, you got unluckily and just happened to estimate a value for $$\bar{x}$$ that is larger or smaller than $$\mu$$, even though, in reality the true value for $${x}$$ in the population really is $$\mu$$.

To figure this out you calculate either a z value (if your n is "large," say > 30) or a t value (if it's < 30 or so). What does this value tell you? Well, we know from the central limit theorem that the errors associated with random sampling (that is - the extent to which an estimate from a sample will deviate from the true value in the population) follow a normal ("z") curve when the sample size is large, and a t curve when the sample size is small. In other words, if we drew a zillion different samples of size n and estimated $$\bar{x}$$ in each, the distribution of these estimates would form a normal/t curve around the true value $${x}$$. How does this help us?

Let's start by assuming that the true value for $${x}$$ in the population really is $$\mu$$. Then let's draw a z or t curve around $$\mu$$. That curve falls away as we get further away from $$\mu$$, indicating that, if $${x}$$ really was equal to $$\mu$$ it would be less and less likely for us to have gotten unluckily enough to have estimated a value for $$\bar{x}$$ that was that far away from $$\mu$$.

In essence the z or t value tells you the number of standard deviations that your estimated value $$\bar{x}$$ is from $$\mu$$ on the appropriate z or t curve. So the bigger the t/ or z value, the less likely it is that $$\bar{x}$$ is actually $$\mu$$ and the more likely it is that they are different. By calculating the area under the z or t curve up to the z/t value (this is something we usually ask a computer to do) we actually estimated we can precisely estimate HOW unlikely (this is what's called a p value). So if we got a z value of 1.96 (around 2 standard deviations away) this means that, if $$\bar{x}$$ really were exactly equal to $$\mu$$ and we drew a zillion different size n samples from this same population, in less than 5% (p<.05) of them would we have gotten an estimate of $$\bar{x}$$ that is as far away from $$\mu$$ as we observe in the data we actually collected. Thus, as long as our samples really were random, we can be pretty confident that our estimated value $$\bar{x}$$ probably IS different from $$\mu$$.

From Wikipedia:

A Z-test is any statistical test for which the distribution of the test statistic under the null hypothesis can be approximated by a normal distribution. Z-test tests the mean of a distribution.