2025-04-11

What is Hypothesis Testing?

Hypothesis testing is a method of making statistical decisions using experimental data. It is used to infer whether a hypothesis about a population parameter should be accepted or rejected.

Steps in Hypothesis Testing

  1. State the null hypothesis \(H_0\) and alternative hypothesis \(H_a\).
  2. Choose a significance level \(\alpha\).
  3. Collect data and calculate a test statistic.
  4. Make a decision: reject or fail to reject \(H_0\).

Null and Alternative Hypotheses (LaTeX)

Example:

  • Null hypothesis \(H_0: \mu = 50\)
  • Alternative hypothesis \(H_a: \mu \neq 50\)

Two-tailed test with significance level \(\alpha = 0.05\).

Example Formula (LaTeX)

Test statistic (z-test for mean):

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

Code Example: Simulate Data and Test

set.seed(123)
sample_data <- rnorm(100, mean = 51, sd = 10)

sample_mean <- mean(sample_data)
sample_sd <- sd(sample_data)
n <- length(sample_data)
z_stat <- (sample_mean - 50) / (sample_sd / sqrt(n))
p_value <- 2 * (1 - pnorm(abs(z_stat)))

list(z_stat = round(z_stat, 2), p_value = round(p_value, 4))
## $z_stat
## [1] 2.09
## 
## $p_value
## [1] 0.037

ggplot2 Plot #1: Histogram of Sample Data

ggplot2 Plot #2: Critical Regions

plotly Plot: Interactive p-value Area

Summary

  • Hypothesis testing helps make data-driven decisions.
  • Small p-value \((p < \alpha)\) means strong evidence against \(H_0\).
  • Large sample size improves the reliability of results.
  • Visualization enhances understanding of critical regions and p-values.

Thank You!

Thank you for learning about Hypothesis Testing.