Reject $H_0$ in favor of $H_1$ if
$\bar X > \mu_0 + z_\alpha \sqrt {\frac{\sigma^2}{n}}$
Note that we use the standard of specifying $\alpha$ as the area to the right on the standard normal curve (e.g., $z_{0.05} = 1.645$). In [[R]], use `qnorm(1 - alpha)`.
## Example
Consider a simple case where we want to test to determine if a sample of size $n=10$ from the normal distribution with known variance $\sigma^2 = 4$ has mean $3$ or with mean $5$ with [[level of significance|size]] $\alpha = 0.05$.
$
\begin{align}
H_0: \mu = 3 && H_1: \mu = 5
\end{align}
$
Let's use the sample mean $\bar X$ as the estimator.
We will reject $H_0$ in favor of $H_1$ if $\bar X > c$.
Given our level of significance, we can calculate the critical value $c$.
$P(\text{Type I Error}) = P(\bar X > c \ ;\ \mu = 3) = 0.05$
We can standardize $\bar X$ to the standard normal distribution
$P(\frac{\bar X - \mu_0}{\sigma / \sqrt{n}} > \frac{c - 3}{2/\sqrt{10}}) = P(Z > \frac{c - 3}{2/\sqrt{10}})= 0.05$
Note that by pulling the value $\mu = 3$ in for $\mu_0$ we have used up the information to the right of the semi-colon and can drop that from our notation.
Looking up the value for $Z$ from the standard normal table and solving for $c$ we get
$\begin{align}
\frac{c - 3}{2/\sqrt{10}} = -1.645 \\
c \approx 4.04
\end{align}$
Thus, our test will reject $H_0$ in favor of $H_1$ if $\bar X > 4.04$.
> [!NOTE]
> Imagine we set the hypotheses up in the opposite way, such that $H_0: \mu = 3$ and $H_1: \mu = 5$. How would our results differ? In this case, we would reject $H_0$ in favor of $H_1$ if $\bar X < 3.96$. #expand What are the confidence intervals for each hypothesis?
#diagram See Week 1 Lesson 5 5003
# for small sample sizes
A t-test is used to compare the means of one or two samples, when the underlying population parameters of those samples (mean and variance) are unknown. Use the [[t-distribution]] to find the critical value. The t-test is only appropriate when the sample follows a normal distribution.
When we substitute the sample variance in for the population variance, we can show that this new random variable has approximately a t-distribution.
#expand see DTSA5003 Week 3 Lesson 3