Interview's MateData Science
Interview's Mate

Data Science

Python → ML → MLOps

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Data Science topics
Lesson 53/ 160
03. Mathematics & Statistics

Type I & Type II Errors & Statistical Power

Balance false positives/negatives and size experiments for adequate statistical power.

AdvancedType I/II · Power3 quiz questions
Practice Generative AI Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

A false positive says something changed when it didn't; a false negative misses a real change; power is the chance you'll spot a real change.

Think of it like…

A smoke detector: Type I is a false alarm when there's no fire; Type II is silence during a real fire. Raising sensitivity reduces missed fires but increases false alarms; a bigger, better detector (more data) improves both.

Where you’ve seen it

Baseline conversion is 10% and the team wants to detect a lift to 11% (a 1-point absolute lift) with α = 0.05 (two-sided) and 80% power. The sample size per group is n = (1.96 + 0.84)² × [0.10 × 0.90 + 0.11 × 0.89] / 0.01² = 7.84 × 0.1879 / 0.0001 ≈ 14,700. With only 5,000 users per arm the standard error of the difference is about 0.0061, the effect is 1.63 standard errors, and power is about 37%: the test would miss a real 1-point lift roughly two times in three. Running it anyway and reading "not significant" as "no effect" would be a mistake.

Words you’ll hear

Type I error (α)
Rejecting a true null: a false positive.
Type II error (β)
Failing to reject a false null: a false negative.
Power (1 − β)
Probability of detecting a true effect of a specified size.
Minimum detectable effect (MDE)
The smallest effect the test is designed to detect with the chosen power.

Visual diagram

Loading interactive diagram

Theory & deep dive

α, β and power

α is chosen by you (0.05 typically). β depends on the true effect, the variability, the sample size and α. Visualise two sampling distributions: one centred at the null value and one at the true effect; the rejection region (set by α) cuts the null distribution's tail, and the part of the alternative distribution that falls outside the rejection region is β. Moving the two distributions apart (a larger effect), narrowing them (a larger n or lower variance) or moving the cut-off (larger α) all raise power.

Typical targets: α = 0.05 and power = 0.80 (β = 0.20), sometimes 0.90 for important decisions. The relative seriousness of errors should guide the choice: in drug safety a false negative may be worse; in a feature launch with a costly rollout, a false positive may be worse. Power is always relative to a specific effect size: a test with 80% power for a 2-point lift may have 20% power for a 0.5-point lift.

Power for a fixed n

Two groups of 5,000 users; baseline 10%, true rate 11%. SE of the difference ≈ √(0.09/5000 + 0.0979/5000) ≈ 0.0061. Standardised effect = 0.01 / 0.0061 ≈ 1.63; power = P(Z > 1.96 − 1.63) ≈ P(Z > 0.33) ≈ 37%.

Key takeaway: Power depends on effect size, n, variability and α; always state the effect it refers to.

Sample-size planning in practice

For two proportions the per-group sample size is n ≈ (z₁₋α/₂ + z₁₋β)² × [p₁(1 − p₁) + p₂(1 − p₂)] / (p₂ − p₁)²; for two means n ≈ 2 (z₁₋α/₂ + z₁₋β)² σ² / δ². With α = 0.05 (two-sided) and 80% power, (1.96 + 0.84)² = 7.84, so n per group ≈ 15.7 σ² / δ² for means. Note the 1/δ² scaling: halving the detectable effect quadruples the sample size. Software does this for you: statsmodels.stats.power.NormalIndPower().solve_power(effect_size=h, alpha=0.05, power=0.8) for proportions (effect size as Cohen's h) and TTestIndPower for means.

Practical considerations: choose the minimum detectable effect from business value (the smallest lift worth shipping), estimate baseline rates and variance from historical data, account for unequal splits and attrition, plan duration from daily traffic (14,700 per arm at 3,000 users a day per arm is about 5 days, but run full weeks to cover weekday cycles), and consider variance reduction (CUPED, stratification) to cut required n. If the required sample is infeasible, say so: either accept a larger MDE, use a more sensitive metric, or don't run the test. Never compute power after the fact from the observed effect ("post-hoc power"); report the interval instead.

Solving for n with statsmodels

h = proportion_effectsize(0.11, 0.10); NormalIndPower().solve_power(effect_size=h, alpha=0.05, power=0.8, ratio=1) returns about 14,700 per group, matching the hand formula.

Key takeaway: Fix MDE, α and power, then solve for n; n scales with 1/δ².

How it works, step by step

Step 1 of 4
Business + analyst

1. Choose the minimum detectable effect

Decide the smallest lift worth acting on, from value and cost, not from what's easy to detect.

10% → 11%
Key numbers at this step
Smaller MDE
needs far more data

When to use it & trade-offs

What it is

A test can go wrong in two ways. A Type I error (false positive) rejects a true H₀: you claim an effect that isn't there, with probability α. A Type II error (false negative) fails to reject a false H₀: you miss a real effect, with probability β. Statistical power = 1 − β is the probability of detecting an effect of a given size when it exists. Power rises with a larger effect size, a larger sample size, a higher α and lower noise. Sample-size planning chooses n so that power (commonly 80%) is adequate for the smallest effect worth detecting.

Why it matters: Underpowered experiments are the norm in practice: teams run a test for a week, see "no significant difference", and conclude the change doesn't matter, when the test could never have detected the effect they cared about. Power analysis before an experiment tells you whether it can answer the question, how long it must run, and how to trade α, β and cost. It's a core experimentation skill.

When to reach for it

  • Sizing A/B tests and surveys
  • Interpreting non-significant results
  • Trading speed against certainty

When to avoid or be careful

  • Running tests with unknown power
  • Concluding "no effect" from an underpowered test
  • Post-hoc power calculations

Levers on power

Increase sample size
Best for: Most direct way to gain power

Strengths: Works for any effect size.

Watch out: Time and cost grow quickly for small effects.

Reduce variance (CUPED, stratification, better metrics)
Best for: Noisy metrics

Strengths: More power without more traffic.

Watch out: Needs pre-experiment data or good covariates.

Raise α or accept a larger MDE
Best for: Low-risk, reversible decisions

Strengths: Smaller required n.

Watch out: More false positives or only large effects detectable.

Interview signals & numbers to know

When this topic comes up

  • “How long should the experiment run?”
  • “We saw no significant difference”
  • “Type I vs Type II error”
  • Minimum detectable effect
  • Sample size calculation

Benchmarks & rules of thumb

≈ 14,700 -
per-group n for 10% → 11% at 80% power
≈ 37% -
power with 5,000 per group in that example
1/δ² -
how required n scales with effect size

Common mistakes & follow-ups

Common interview mistakes

  • Declaring a feature "doesn't move conversion" after a 5,000-user test that had 37% power.
  • Choosing the MDE after seeing what the data could show.
  • Stopping early because the traffic target was reached, before covering full weekly cycles.

Likely interviewer follow-ups

  • How do Type I and Type II errors differ?
  • How would you size an A/B test?
  • How can you increase power without more users?
Interview tip: Always tie power to a specific effect: "80% power to detect a 1-point lift". Power without an effect size is meaningless.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply Type I & Type II Errors & Statistical Power with data science interview Q&A and hands-on practice.

Open Data Science Q&A →Machine Learning Q&A
Previous topic
P-values & Statistical Significance
Next topic
Z-test, T-test & Chi-Square Test