8.3: Tests for a Single Mean (z and t-tests)
- Page ID
- 58926
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\( \newcommand{\dsum}{\displaystyle\sum\limits} \)
\( \newcommand{\dint}{\displaystyle\int\limits} \)
\( \newcommand{\dlim}{\displaystyle\lim\limits} \)
\( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)
( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\id}{\mathrm{id}}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\kernel}{\mathrm{null}\,}\)
\( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\)
\( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\)
\( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)
\( \newcommand{\vectorA}[1]{\vec{#1}} % arrow\)
\( \newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow\)
\( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vectorC}[1]{\textbf{#1}} \)
\( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)
\( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)
\( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\(\newcommand{\longvect}{\overrightarrow}\)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)Ready to put the hypothesis testing process to work? In this section, we’ll walk through a full hypothesis test using a scenario that compares a sample mean to a known population mean using a z-test statistic.
Before we begin, let's clear up the difference between z-tests and t-tests, since you'll see both in this course.
Z-test vs. T-test
The formula for both is similar, but the test statistic depends on what we know:
- Z-test: Use when the population standard deviation \( \sigma \) is known.
- T-test: Use when \( \sigma \) is unknown and must be estimated with the sample standard deviation \( s \)
Z-test statistic:
\( Z = \frac{\bar{x} - \mu_0}{\frac{\sigma}{\sqrt{n}}} \)
this test statistic will fall somewhere in the normal distribution.
T-test statistic:
\( T = \frac{\bar{x} - \mu_0}{\frac{s}{\sqrt{n}}} \)
this test statistic will fall somewhere in the Student t-distribution.
Both represent standardized distances between your sample mean and the hypothesized mean under \( H_0 \) but within different distributions. We'll start with the easier case — when population \( \sigma \) is known — and revisit t-tests soon.
Once we have calculated our test statistic, we want to know: how extreme is this result if the null hypothesis were true? This is where the p-value comes in. The p-value helps us quantify whether our sample provides evidence against the null.
Definition: p-value
The p-value is the probability of observing a test statistic as extreme or more extreme than what we found in our sample, assuming the null hypothesis is true.
It reflects how surprising our result is under the assumption that \( H_0 \) is correct.
Choosing Left, Right, or Two-Tailed
The structure of your alternative hypothesis (\( H_A \)) determines which direction you're testing. Before you collect any data, decide what direction your test should examine and clearly state the form of your alternative hypothesis. The direction matters because it tells us where to look on the sampling distribution for unusual results: in the left tail, right tail, or both.
- Left-tailed test: Use when you are testing whether the population mean is less than the null value. Example: \( H_A: \mu < \mu_0 \)
For a left tailed test, the p-value will be \( P( T<T_{obs})\) - Right-tailed test: Use when you are testing whether the mean is greater than the null value. Example: \( H_A: \mu > \mu_0 \)
For a right tailed test, the p-value will be \( P(T>T_{obs})\). - Two-tailed test: Use when you are testing whether the mean is simply different from the null value — that is, either greater or less. Example: \( H_A: \mu \ne \mu_0 \)
Two-tailed tests require computing the probability in the "tail" and then doubling it.
The smaller the p-value, the stronger the evidence against the null. Now that we have our test statistic and a way to interpret it, we’re ready to step through a full hypothesis test example.
Example 1: “Traffic is so much worse these days”
You've heard it before: someone groans, “Traffic is AWFUL lately. It used to take 30 minutes to drive to work — now it takes forever.”
You’re curious: Is this backed up by data, or just selective memory?
You record your commute time on the same route over 36 different days. The known historical average commute time is \( \mu = 30 \) minutes, with population standard deviation \( \sigma = 5 \) minutes. Your sample has an average time of \( \bar{x} = 32 \) minutes.
Step 1: State the Hypotheses
We set up hypotheses to test a claim of change:
- \( H_0: \mu = 30 \) (the average is still the same)
- \( H_A: \mu > 30 \) (average commute time is greater today)
Step 2: Select Test and Statistic
We're testing one sample mean against a known \( \mu \), and \( \sigma \) is known → use a z-test.
\( Z = \frac{\bar{x} - \mu}{\frac{\sigma}{\sqrt{n}}} = \frac{32 - 30}{\frac{5}{\sqrt{36}}} = \frac{2}{\frac{5}{6}} = \frac{2}{0.8333} \approx 2.40 \)
Step 3: Set the Significance Level \( \alpha \)
Let’s use \( \alpha = 0.05 \) (5%) as the threshold for rejecting \( H_0 \).
Step 4: Calculate P-value
Find the area to the right of z = 2.40 in the normal distribution using the z-table or technology. This is a right-tailed test since \(H_A\) contains "greater than".
\( P(Z > 2.40) = 0.0082 \)
Step 5: Make a Conclusion
The P-value represents the probability of seeing our sample mean or greater if we assume the population mean is still 30min. Since 0.0082 < 0.05, we reject \( H_0 \). Our sample results significantly unlikely to have occured randomly if \(H_0\) is true, so we reject the \(H_0\) assumption.
Conclusion: There is strong evidence that commute times are longer now than they used to be.
Example 2: “Are students sleeping less during finals week?”
You suspect that students at your school get less sleep during finals week than during a typical week.
Previous studies say college students average 7 hours of sleep per night (on a non-finals week). You collect a sample of 50 students and find they average 6.6 hours of sleep during finals week. Assume the population standard deviation is \( \sigma = 1.2 \) hours.
Try walking through the five steps using a z-test!
- State your null and alternative hypotheses.
- Compute the z test statistic using \( \bar{x} = 6.6, \mu = 7, \sigma = 1.2, n = 50 \)
- Choose a significance level (we can just use \( \alpha = 0.05\) again)
- Find the p-value using a z-table or technology.
- Make a decision using \( \alpha = 0.05 \) and write your conclusion in the context of the problem.
Hint: This is a left-tailed test (you are testing if sleep is less than usual).
Example 3: “Are coffee drinkers at this café drinking more than the national average?”
A nationwide survey reports that the average amount of coffee consumed by adults is 2.7 cups per day. You suspect that customers at your local independent café might drink more than average, so you decide to collect some data.
You randomly sample 15 customers and ask each how many cups of coffee they’ve had that day. Your sample has an average of \( \bar{x} = 3.1 \) cups, with a sample standard deviation of \( s = 0.75 \) cups.
Question: Based on your sample, is there evidence that your local café customers drink more coffee than the national average?
Step 1: State the Hypotheses
- \( H_0 : \mu = 2.7 \)
- \( H_A : \mu > 2.7 \)
This is a one-tailed (right-tail) test. We’re looking for evidence that the average is higher than the known population mean.
Step 2: Use a t-test (σ unknown)
Since we do not know the population standard deviation and have a small sample size (n = 15), we’ll use the t-distribution.
Calculate the test statistic:
\[ t = \frac{\bar{x} - \mu_0}{\frac{s}{\sqrt{n}}} = \frac{3.1 - 2.7}{\frac{0.75}{\sqrt{15}}} = \frac{0.4}{0.1938} \approx 2.06 \]
Step 3: Choose Significance Level
Use \( \alpha = 0.05 \)
Step 4: Two Approaches to Making a Decision
There are two common methods used to reach a decision in hypothesis testing. When using technology, we usually use the p-value method, but if you're using the t-table, you would use the Critical Value method. Both methods use the same test statistic, but frame the conclusion differently. Let's examine both side by side:
| p-value Method | Critical Value Method |
|---|---|
|
|
Step 5: Decision
Since \( p = 0.030 < 0.05 \), we reject \( H_0 \).
Conclusion: There is statistically significant evidence that customers at this café drink more coffee than the national average.
This result suggests the higher average is more than just random chance, these customers really do seem to consume more coffee than elsewhere in the country.
Looking Ahead: Two Means
What if we want to compare two groups — like students in an afterschool program vs. a control group?
To compare two sample means, we’ll use the two-sample t-test. If we do not assume equal variances, we use Welch’s t-test:
\( T = \frac{\bar{x}_1 - \bar{x}_2}{\sqrt{\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}}} \)
We’ll explain this formula and when to use it in the next section. But for now, remember: the logic stays the same. Hypotheses, test statistic, p-value, decision, conclusion.


