Hypothesis testing is a statistical method used to determine whether there is enough evidence to support a claim.
2026-06-05
Hypothesis testing is a statistical method used to determine whether there is enough evidence to support a claim.
The null hypothesis represents the default claim.
\[ H_0 : \mu = \mu_0 \]
The alternative hypothesis represents the competing claim.
\[ H_a : \mu \neq \mu_0 \]
A test statistic measures how far the sample result is from the null hypothesis.
\[ z = \frac{\bar{x}-\mu_0}{\sigma/\sqrt{n}} \]
where:
\(\bar{x}\) = sample mean
\(\mu_0\) = hypothesized mean
\(\sigma\) = population standard deviation
\(n\) = sample size
The normal distribution is useful in hypothesis testing because many test statistics follow an approximately normal shape.
Suppose we collected the following exam scores from a sample of students.
## Student Score ## 1 A 72 ## 2 B 85 ## 3 C 91 ## 4 D 78 ## 5 E 88
The following code calculates the average score from our sample data.
sample_data <- data.frame(
Student = c("A", "B", "C", "D", "E"),
Score = c(72, 85, 91, 78, 88)
)
mean(sample_data$Score)
## [1] 82.8