Hypothesis Testing: Real Effect or Random Noise?
The A/B Testing Problem
You work at an e-commerce company. The design team created a new checkout button - green instead of blue. After running both versions for a week:Difficulty: Intermediate
Prerequisites: Modules 1-4 (especially Distributions and Inference)
What You’ll Build: Complete A/B testing framework
The Framework: Innocent Until Proven Guilty
Hypothesis testing borrows from the legal system:The Two Hypotheses
Null Hypothesis (H₀): The default assumption. Nothing special is happening.- “The new button has the same conversion rate as the old one”
- “The drug has no effect”
- “The two groups are the same”
- “The new button has a different conversion rate”
- “The drug has an effect”
- “The groups are different”
The P-Value: Quantifying Surprise
The p-value answers: “If there really were no effect, how likely would we be to see data this extreme?”Interpreting P-Values
- If p < 0.05, we reject the null hypothesis
- If p ≥ 0.05, we fail to reject the null hypothesis
Testing Our A/B Example
Let’s test whether the green button is actually better:Method 1: Two-Proportion Z-Test
- What we observed: Green button had 0.35 percentage points higher conversion.
- What we asked: If there were truly no difference, how often would we see a gap this large by luck alone?
- What we found: About 16% of the time (p = 0.16). That is not particularly rare.
- Our decision: Since 16% is above our 5% threshold, we cannot confidently say the green button is better. The observed difference is plausible under random noise.
- What this does NOT mean: It does not mean the green button is NOT better. It means we do not have enough evidence to conclude either way. A larger sample might reveal a real difference.
Method 2: Chi-Square Test
Types of Errors
We can make two types of mistakes:Type I Error (α): False Positive
We claim there’s an effect when there isn’t one.- Probability = α (typically 0.05)
- “The boy who cried wolf”
- Example: Launching a feature that doesn’t actually help
Type II Error (β): False Negative
We miss a real effect.- Probability = β (varies, often 0.20)
- Power = 1 - β (typically 0.80)
- Example: Abandoning a feature that would have helped
Statistical Power: Ability to Detect Real Effects
Power = Probability of detecting an effect when it exists = 1 - β Higher power means:- Less likely to miss real effects
- Requires larger sample sizes
- More confidence in negative results
Sample Size Calculation for Desired Power
Common Statistical Tests
1. One-Sample t-Test
Is this sample mean different from a known value?2. Two-Sample t-Test
Are the means of two groups different?3. Paired t-Test
Before/after comparisons on the same subjects:4. ANOVA
Are three or more groups different?Complete A/B Testing Framework
Common Mistakes to Avoid
1. Peeking and Early Stopping
2. Multiple Testing Without Correction
Interview Questions
Question 1: A/B Test Interpretation (Google)
Question 1: A/B Test Interpretation (Google)
Question 2: Multiple Testing (Amazon)
Question 2: Multiple Testing (Amazon)
Question 3: Power and Sample Size (Facebook/Meta)
Question 3: Power and Sample Size (Facebook/Meta)
Question 4: Early Stopping (Tech Companies)
Question 4: Early Stopping (Tech Companies)
Practice Challenge
Challenge: Build a Complete A/B Testing Framework
Challenge: Build a Complete A/B Testing Framework
📝 Practice Exercises
Exercise 1
Exercise 2
Exercise 3
Exercise 4
Key Takeaways
The Framework
- Null hypothesis: no effect (innocent)
- Alternative: there is an effect
- P-value: how surprising is the data?
- Decision threshold: typically α = 0.05
Types of Errors
- Type I (α): False positive, claiming effect that doesn’t exist
- Type II (β): False negative, missing real effect
- Power = 1 - β: Ability to detect real effects
Sample Size Matters
- Small samples = low power = missed effects
- Calculate sample size BEFORE running test
- More precision requires exponentially more data
Test Selection
- Two proportions: Chi-square or z-test
- Two means: t-test
- Multiple groups: ANOVA
- Non-normal: Mann-Whitney U
Common Pitfalls
Connection to Machine Learning
Next: Correlation and Regression
Interview Deep-Dive
Your A/B test has p=0.04. Product wants to ship. Engineering wants more data. Who is right?
Your A/B test has p=0.04. Product wants to ship. Engineering wants more data. Who is right?
- Neither is automatically right — the answer depends on context that a p-value alone does not provide. A p=0.04 means the result is technically significant at alpha=0.05, but there are several things I would check before making a recommendation.
- First, what is the effect size? If the new variant improved conversion by 0.02 percentage points (from 3.00% to 3.02%), the result may be statistically significant with a large enough sample but practically meaningless. Shipping a code change, increasing technical debt, and potentially confusing users for a 0.02pp improvement is not worth it. I would compute the expected annual revenue impact and compare it to the implementation cost.
- Second, what is the power of the test? If we planned for 80% power to detect a 10% relative lift but only ran enough traffic for 50% power, then p=0.04 might be an inflated estimate (the “winner’s curse” — significant results from underpowered tests tend to overestimate effect sizes).
- Third, did anyone peek at the data before the test concluded? If the team checked results daily, the effective alpha is much higher than 0.05 due to multiple comparisons, and p=0.04 may not actually be significant under the true (inflated) alpha.
- My recommendation: if the effect size is meaningful, the test was pre-registered, and nobody peeked, ship it. If any of those conditions are not met, run a confirmation test or extend the current one.
Explain the difference between statistical significance and practical significance with a concrete example.
Explain the difference between statistical significance and practical significance with a concrete example.
- Statistical significance means the observed difference is unlikely to have occurred by chance alone. Practical significance means the difference is large enough to actually matter for the business.
- Concrete example: an e-commerce company runs an A/B test on 2 million users and finds the new homepage increases average order value from 47.35. With that sample size, the p-value is 0.001 — highly statistically significant. But the actual improvement is 150K annually. If the homepage redesign cost $500K in engineering time and introduced new technical debt, the statistically significant result is practically worthless.
- Conversely, a startup tests a new pricing page on 500 users and sees a conversion lift from 3% to 5%. The p-value is 0.08 — not statistically significant at alpha=0.05. But the 67% relative lift, if real, would double the company’s revenue. The practical significance is enormous; the test was just underpowered. The right action is to run longer, not to conclude “no effect.”
- The way I think about it: p-values tell you whether the signal is distinguishable from noise. Effect size and business context tell you whether the signal matters. You need both.
What is p-hacking, and how would you design an experimentation platform to prevent it?
What is p-hacking, and how would you design an experimentation platform to prevent it?
- P-hacking is the practice of manipulating data analysis to find statistically significant results. Common forms include: checking results daily and stopping when p drops below 0.05, testing multiple metrics and only reporting the one that is significant, segmenting data after the fact to find a subgroup where the effect is significant, or adding and removing covariates until significance appears.
- Each of these inflates the false positive rate well beyond the nominal 5%. A team that checks daily for 14 days has effectively run 14 tests, pushing the real false positive rate to roughly 25-30%. A team that tests 20 metrics will find at least one “significant” result by chance alone.
- To prevent it at the platform level, I would design the system with these guardrails: (1) Pre-registration: require teams to specify the primary metric, sample size, and analysis plan before the test launches. Lock these parameters. (2) Sequential testing: use methods like always-valid p-values or group sequential designs that allow continuous monitoring without inflating the error rate. (3) Automated correction: when multiple metrics are tracked, automatically apply Benjamini-Hochberg correction and highlight the distinction between primary and exploratory metrics. (4) Mandatory effect size reporting: always show the confidence interval for the effect size alongside the p-value. (5) Cool-off period: require a minimum test duration covering at least one full business cycle before results can be acted upon.
- The cultural piece is equally important: incentivize teams for running well-designed experiments regardless of outcome, not just for finding “winners.”
You are running 10 A/B tests simultaneously. Three come back significant at p less than 0.05. How many of those are likely real?
You are running 10 A/B tests simultaneously. Three come back significant at p less than 0.05. How many of those are likely real?
- Under the null hypothesis (no effect for any test), the expected number of false positives from 10 tests at alpha=0.05 is 0.5. So getting 3 “significant” results when you run 10 tests is suspicious — at least some are likely false positives.
- However, it is unrealistic to assume all 10 nulls are true. If you are testing reasonable product changes, maybe 3-4 of them actually have real effects. In that case, 3 significant results might include 2-3 real effects and 0-1 false positive.
- The standard corrections are Bonferroni (divide alpha by the number of tests, requiring p less than 0.005) and Benjamini-Hochberg (FDR control, which is less conservative). Bonferroni controls the family-wise error rate but is very strict — you might miss real effects. BH controls the false discovery rate, saying “of the results I call significant, at most X% are false.”
- The best practice is to flag all 3 as candidates, apply BH correction to see which survive, and then run a focused confirmation test on the 1-2 that survive correction. The confirmation test uses fresh data and a single pre-specified hypothesis, eliminating the multiple testing problem entirely.