A/B testing
Statistics · 13 questions
Short notes
Key idea
An A/B test splits users at random into two groups, shows each a different version and compares one main metric. Random assignment is what lets you say the change caused the difference.
Syntax
- Hypothesis and one primary metric (conversion rate).
- Sample size from the baseline rate, the smallest lift you care about, α = 0.05 and power = 0.8.
- Randomise by user, run full weeks, don't stop early.
- Test: two-proportion z-test or chi-square; report the lift with a confidence interval.
from statsmodels.stats.proportion import proportions_ztest
proportions_ztest([conv_b, conv_a], [n_b, n_a])
Example
A: 500 of 10,000 convert (5.0%). B: 580 of 10,000 (5.8%). p ≈ 0.01, so B's lift of 0.8 points is unlikely to be chance. Check guardrail metrics like refunds before shipping.
Traps
- Peeking and stopping when p < 0.05 inflates false positives.
- Sample ratio mismatch (a 50/50 split that came out 52/48) means the split is broken.
- Too many metrics: one of them will "win" by chance.
- Novelty effect: users click new things at first; run long enough.
Want the full lesson with step-by-step examples, a project and a certificate? Statistics course, ₹120 →
- Question 1easy
Why must users be assigned to A or B randomly?
- Question 2medium
A PM checks the test every morning and stops it the first day p < 0.05. What's wrong?
- Question 3medium
Which is the best unit to randomise for a checkout-page test?
- Question 4medium
What does this print?
p_a = 120 / 2400 p_b = 156 / 2400 print(round((p_b - p_a) / p_a, 2))
- Question 5hard
What does this print?
import math n_a = n_b = 2400 p_a, p_b = 120 / n_a, 156 / n_b p = (120 + 156) / (n_a + n_b) se = math.sqrt(p * (1 - p) * (1 / n_a + 1 / n_b)) print(abs((p_b - p_a) / se) > 1.96)
A/B testing
A/B testing
A/B testing
A/B testing
A/B testing
8 more questions on this topic, with hints, and tests
Sign up free for 21 days of every question and test.