Skip to content

Hypothesis Testing (p-value, alpha, errors)

  1. Define null hypothesis (H0) and alternative (H1)
  2. Choose a significance level (\alpha) (commonly 0.05)
  3. Compute a test statistic and p-value
  4. Decide whether to reject H0

A p-value is:

  • Probability of seeing results at least as extreme as your observation if H0 were true.

Low p-value means:

  • Data is unlikely under H0 → evidence against H0
  • Type I error: reject H0 when H0 is true (false positive). Probability ≈ (\alpha).
  • Type II error: fail to reject H0 when H0 is false (false negative). Probability = (\beta).
  • Power: (1 - \beta)

Is the average delivery time different from 30 minutes?

One-sample t-test
import numpy as np
from scipy import stats
 
x = np.array([28, 32, 31, 29, 26, 30, 33, 27])
 
t_stat, p = stats.ttest_1samp(x, popmean=30)
print("t:", t_stat)
print("p:", p)
  • Report effect size + CI, not just p-value.
  • Don’t equate “not significant” with “no difference”.
  • Predefine your hypothesis; avoid testing many variants blindly.

This flowchart traces the decision path from stating your hypotheses to accepting or rejecting H0 based on the p-value.

diagram Hypothesis testing decision flow mermaid
From H0/H1 through the p-value comparison to a final decision

Continue to t-test (independent and paired) to apply this decision framework to comparing two groups’ means.

pch.coffeeTagline

pch.coffeeCta

pch.feedbackHeading

pch.feedbackSubheading