Hypothesis testing is a statistical framework used to make decisions about a population based on sample data.
We evaluate evidence by comparing observed results to what would happen under a certain assumption (the null hypothesis).
2025-11-16
Hypothesis testing is a statistical framework used to make decisions about a population based on sample data.
We evaluate evidence by comparing observed results to what would happen under a certain assumption (the null hypothesis).
We want to test whether the true mean weight of a product is 50 grams.
\[ H_0: \mu = 50 \] \[ H_1: \mu \neq 50 \]
Suppose we collect a sample of weights and compute the test statistic:
\[ t = \frac{\bar{x} - \mu_0}{s/\sqrt{n}} \]
If \(|t|\) is large, the sample mean is far from the hypothesized value \(\mu_0\).
xbar <- mean(sample_data) s <- sd(sample_data) n <- length(sample_data) mu0 <- 50 t_statistic <- (xbar - mu0) / (s / sqrt(n)) t_statistic
## [1] 4.923414
p_value <- 2 * pt(abs(t_statistic), df = n - 1, lower.tail = FALSE) p_value
## [1] 3.402336e-06
mu0 <- 50 # hypothesized population mean t.test(sample_data, mu = mu0)
## ## One Sample t-test ## ## data: sample_data ## t = 4.9234, df = 99, p-value = 3.402e-06 ## alternative hypothesis: true mean is not equal to 50 ## 95 percent confidence interval: ## 50.79200 51.86133 ## sample estimates: ## mean of x ## 51.32666
xbar
## [1] 51.32666
s
## [1] 2.694598
n
## [1] 100
p_value
## [1] 3.402336e-06