ML Systems Lab Open interactive version →
Intermediate 26 min read statisticshypothesis testingp-valuesA/B testing

Hypothesis Testing

p-values, Type I/II errors, t-test, chi-squared, multiple comparisons

Your team builds a new checkout button — different color, slightly repositioned. You run it for two weeks. 10,000 users see the new version; 10,000 see the old one. Conversion: 3.2% versus 3.0%. The difference is 0.2 percentage points. Is this real, or did you just get lucky?

The question you need to answer: if the button had no effect whatsoever — if both groups were drawn from the same underlying population — how often would random sampling produce a gap of at least 0.2 percentage points just by chance? That probability is the p-value. Work it out for this test: pooled conversion rate ≈3.1%, standard error of the gap ≈0.245 percentage points, so the observed 0.2-point gap is under one standard error from zero — the p-value comes out to about 0.41. A p-value of 0.41 means: if the null hypothesis were true, you would see a difference this large or larger about 41% of the time by chance alone — nowhere near rare enough to reject the null. This particular gap is comfortably explained by noise, not a real effect.

If p falls below your threshold α (commonly 0.05), you reject the null. Type I error (false positive): you rejected when the null was true — happens with probability α. Type II error (false negative): you failed to reject when there was a real effect. The probability of *detecting* a real effect is power $= 1 - β$. Power is not determined by p-values — it is determined before the experiment by choosing your sample size.

Now suppose your product manager runs 20 A/B tests simultaneously, each at α = 0.05. Under the null, each test has a 5% chance of a false positive. With 20 tests, you expect $20 \times 0.05 = 1$ false positive. Finding three "significant" results is entirely consistent with all null hypotheses being true. The Bonferroni correction divides α by the number of tests: test each at $α/20 = 0.0025$. The Benjamini-Hochberg procedure controls the false discovery rate — the fraction of significant results that are false — and is less conservative.

NOT this. Most people read p < 0.05 as "there is a 95% probability the effect is real." Wrong. The p-value is a property of the *data* under the null hypothesis, not a probability about the hypothesis. It says nothing about P(null is true). To compute that, you need a prior — Bayesian territory. A p-value of 0.001 on a 10-million-user-per-arm dataset can come from a conversion lift as small as ≈0.025 percentage points — about a 1% relative lift on a 3% baseline — small enough that many teams would consider it commercially marginal. Statistical significance is not practical significance. Always pair p-values with effect sizes and confidence intervals.

Key points

Takeaway

A p-value measures how often chance produces this result, not how probable the hypothesis is. Effect size tells you whether the result matters. You need both before making a decision.

Recap

Check your understanding

Q1. You run a t-test comparing two groups and get p=0.048. Your colleague says 'we have 95.2% confidence that the effect is real.' Which two of the following identify genuine, correct problems with this statement?

Q2. A clinical trial detects p=0.001 with a treatment effect of 0.2 points on a 100-point quality-of-life scale. N=50,000. Is this finding clinically meaningful? Explain statistical vs practical significance.

Q3. You run 20 A/B tests simultaneously. 3 tests show p < 0.05. How many would you expect by chance, and what correction do you apply?

Try it interactively

ML Systems Lab is a free interview-prep platform for ML engineers — work through the full interactive module, quizzes, and drills.

Open ML Systems Lab →