October 2025

What is Hypothesis Testing?

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

Key Components:

  • Null Hypothesis (\(H_0\)): The default assumption
  • Alternative Hypothesis (\(H_a\)): What we’re trying to prove
  • Test Statistic: Calculated from sample data
  • P-value: Probability of observing the data if \(H_0\) is true
  • Significance Level (\(\alpha\)): Threshold for decision (commonly 0.05)

The Hypothesis Testing Process

Steps:

  1. State the hypotheses (\(H_0\) and \(H_a\))
  2. Choose significance level (\(\alpha\))
  3. Calculate the test statistic
  4. Find the p-value
  5. Make a decision: Reject or fail to reject \(H_0\)
  6. Interpret results in context

Mathematical Framework

The test statistic for a one-sample t-test is calculated as:

\[t = \frac{\bar{x} - \mu_0}{s/\sqrt{n}}\]

Where:

  • \(\bar{x}\) = sample mean
  • \(\mu_0\) = hypothesized population mean
  • \(s\) = sample standard deviation
  • \(n\) = sample size

The degrees of freedom are \(df = n - 1\)

Example: Testing Average Study Hours

Scenario: A professor claims students study an average of 15 hours per week. We sample 30 students to test this claim.

Hypotheses:

\[H_0: \mu = 15 \text{ hours}\] \[H_a: \mu \neq 15 \text{ hours}\]

Significance Level: \(\alpha = 0.05\)

Sample Data and Calculation

# Generate sample data
set.seed(123)
study_hours <- rnorm(30, mean = 17, sd = 4)

# Perform t-test
t_test_result <- t.test(study_hours, mu = 15)

# Display key results
cat("Sample mean:", round(mean(study_hours), 2), "hours\n")
## Sample mean: 16.81 hours
cat("Test statistic:", round(t_test_result$statistic, 3), "\n")
## Test statistic: 2.529
cat("P-value:", round(t_test_result$p.value, 4))
## P-value: 0.0172

Distribution Visualization (ggplot)

Sample Data Distribution (ggplot)

Interactive 3D Visualization (plotly)

Decision and Conclusion

Test Results:

  • Test statistic: 2.529
  • P-value: 0.0172
  • 95% Confidence Interval: [15.35, 18.28]

Decision: Since p-value < 0.05, we reject the null hypothesis.

Conclusion: There is sufficient evidence to conclude that the average study time differs significantly from 15 hours per week. The sample suggests students study approximately 16.8 hours per week.

Types of Errors in Hypothesis Testing

Decision \(H_0\) is True \(H_0\) is False
Reject \(H_0\) Type I Error (\(\alpha\)) Correct Decision
Fail to Reject \(H_0\) Correct Decision Type II Error (\(\beta\))

Key Points:

  • Type I Error: False positive (rejecting true \(H_0\))
  • Type II Error: False negative (failing to reject false \(H_0\))
  • Power = \(1 - \beta\) (probability of correctly rejecting false \(H_0\))