Math & Statistics

Hypothesis Testing & p-values

How to make statistical decisions under uncertainty without being tricked by random noise.

🟡 intermediate5 min readstatisticsexperimentation
Hypothesis testing evaluates whether an observed effect is statistically significant or merely random chance. We set a Null Hypothesis H₀ (no effect) and Alternative Hypothesis H₁ (effect exists), compute a test statistic, and derive a p-value: P(Data | H₀). If p-value < significance level α (typically 0.05), we reject H₀. Key interview topics include Type I vs Type II errors, p-value misinterpretations, Z-test vs t-test, and effect size vs p-value.

The Hypothesis Testing Framework

Every hypothesis test follows 5 rigid steps:

  1. Formulate Hypotheses:
    • Null Hypothesis H₀: No difference / no treatment effect (μ_A = μ_B).
    • Alternative Hypothesis H₁: Treatment effect exists (μ_A ≠ μ_B or μ_B > μ_A).
  2. Choose Significance Level (α): Threshold for Type I error (commonly α = 0.05).
  3. Calculate Test Statistic: e.g., t = (X̄_B - X̄_A) / SE_diff.
  4. Compute p-value: P( Statistic ≥ Observed | H₀ is True ).
  5. Decision Rule:
    • If p-value < α: Reject H₀ (Statistically significant result).
    • If p-value ≥ α: Fail to reject H₀ (Insufficient evidence).

Decision Matrix & Errors

Decision \ TruthH₀ is True (No Effect)H₁ is True (Real Effect)
Reject H₀ (Fire Alert)Type I Error (α) — False AlarmCorrect Decision — Power (1 - β)
Fail to Reject H₀Correct Decision (1 - α)Type II Error (β) — Missed Detection

Z-test vs Student's t-test vs Chi-Square vs ANOVA

TestData TypeScenario
Z-testContinuous / RatesLarge sample (N > 30), known population σ, or Bernoulli rates (CTR).
t-testContinuousSmall sample (N < 30) with unknown σ (Two-sample t-test for A/B testing).
Chi-Square (χ²)CategoricalIndependence of 2 categorical features (e.g. Device Type vs Conversion).
ANOVA (F-test)ContinuousComparing means across 3+ groups simultaneously (prevents alpha inflation).

Say this out loud

"Hypothesis testing determines whether an observed metric difference is statistically significant. The p-value is the probability of seeing data as extreme as ours assuming the null hypothesis H₀ is true. If p < 0.05, we reject H₀. In large-scale online systems with millions of samples, even tiny non-meaningful lifts become statistically significant, so we must pair p-values with practical effect size and confidence intervals."

Follow-ups to expect

Check yourself

Question 1 of 3

What is the exact definition of a p-value?

More in Math & Statistics

See all →
Bayes’ Theorem4 minCentral Limit Theorem4 minLaw of Large Numbers4 min