What is Hypothesis Testing?

Hypothesis testing is a statistical method used to make decisions about a population based on sample data.

Some common questions:

  • Is a new treatment effective?
  • Is a coin fair?
  • Manufacturing process changed?

A hypothesis test can help determine whether the observed data provided enough evidence to support a claim.

Null and Alternative Hypotheses

The two competing hypotheses are:

Null Hypothesis

\[H_0:\mu=\mu_0\]

The population mean equals a specified value.

Alternative Hypothesis

\[H_a:\mu\neq\mu_0\]

The population mean differs from that value.

The goal is to determine whether the data provide sufficient evidence against the null hypothesis.

Test Statistic

A common test statistic for a mean is

\[ 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

Large values of |z| provide evidence against the null hypothesis.

Example Data

A company claims that batteries last 100 hours.

Using tests we collect a sample of battery lifetimes.

##    lifetime
## 1        95
## 2       102
## 3        98
## 4       104
## 5       100
## 6        96
## 7       101
## 8        99
## 9       103
## 10       97

Sample mean:

## [1] 99.5

Histogram of Battery Lifetimes

This graph displays the observed battery lifetimes from our tests.

Scatter Plot with Trend

This plot can help us visualize the variation in the measurements.

Interactive Plotly Visualization

We can zoom and interact with the graph by clicking on it.

Example R Code

The following code computes the sample mean.

mean(battery$lifetime)
## [1] 99.5

The sample mean summarizes the center of the data.

Understanding the p-value

The p-value measures how unusual the observed data are under the null hypothesis.

\[ p = P(\text{data at least as extreme as observed }| H_0) \]

Interpretation:

  • Small p-value → evidence against \(H_0\)
  • Large p-value → insufficient evidence against \(H_0\)

A common significance level is:

\[ \alpha = 0.05 \]

Conclusion

Hypothesis testing is an essential statistical tool.

Key ideas:

  • State null and alternative hypotheses.
  • Compute a test statistic.
  • Calculate a p-value.
  • Draw a conclusion.

These methods are widely used in science, engineering, business, and data analysis.