what is hypothesis testing

hypothesis testing is a statistical method for making decisions about population parameters based on sample data. we test an assumption (null hypothesis) and use data to determine whether to reject it.

example problem

a company claims its light bulbs last 1000 hours on average. we take a sample of 50 bulbs and find their average lifetime. we want to test whether the true mean differs from 1000 hours.

hypothesis test formulas

\[ H_0: \mu = 1000 \]

\[ H_a: \mu \neq 1000 \]

test statistic for known variance:

\[ z = \frac{\bar{x} - \mu_0}{\sigma / \sqrt{n}} \]

p-value explanation

p-value is the probability of observing a test statistic as extreme or more extreme, assuming the null hypothesis is true.

\[ p = P(Z \geq |z_{obs}|) \]

small p-value → evidence against \(H_0\).

simulated sample data (ggplot histogram)

## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
## [1] 993.3516
## [1] 44.89638

CONCLUSION!

Hypothesis testing allows us to make data-driven decisions. in this example, we used sample data to assess whether the company’s claim about light bulb lifetimes was supported. using p-value and test statistics, we can evaluate whether to reject \(H_0\).