26 — Make Decisions

Power Analysis#

PlanningStatistical 1 min read
◆ The PatternHow much data do you need? Sample size planning for experiments that can actually detect effects

Statistical power is the probability of detecting a real effect if one exists. Convention: aim for 80% power. Power analysis links four quantities — sample size, effect size, significance level, and power — so you can solve for any one given the other three.

Power = 1 − β = P(reject H0 | H1 true)
Power = 0.80 means 80% chance of detecting a real effect. β = Type II error rate.
// Interactive — sample size vs power curve
Effect size d0.50
Alpha0.05
N needed—
Before you experiment: Do the power analysis first. If you need 500 samples per group and can only get 50, the experiment is doomed before it starts.
Pattern bridge: Too little data and a real effect stays invisible. The same arithmetic decides how long an A/B rollout has to run, and how much history you need before a backtest can tell skill from luck.
Worked example

To detect a standardised effect with 80% power at the 5% level takes about 393 people per group for d = 0.2, 63 for d = 0.5 and 25 for d = 0.8. A study with 30 per group has only 49% power for a medium effect of 0.5 — a coin flip whether it finds an effect that is really there.

Where it misleads
  • Power calculations need a guess of the effect size; guessing from a small pilot study usually overestimates it.
  • Computing “observed power” after a study is uninformative; it is just a restatement of the p-value.
  • Low-powered studies that do find effects tend to exaggerate them (Button et al. 2013).
In code
from scipy.stats import norm
z = norm.ppf(0.975) + norm.ppf(0.80)
n_per_group = {d: int(np.ceil(2 * z ** 2 / d ** 2)) for d in (0.2, 0.5, 0.8)}   # normal approximation
power_30 = norm.cdf(0.5 * np.sqrt(30 / 2) - norm.ppf(0.975))                   # d = 0.5 with 30 per group
Python, in your browser — edit the code and run it again

Assumes import numpy as np and import pandas as pd (and SciPy where imported). Each snippet simulates or makes up its own data, as the comments say.

The same idea with a library
# Python — power analysis
from statsmodels.stats.power import TTestIndPower

analysis = TTestIndPower()

# How many samples for d=0.5, power=0.8?
n = analysis.solve_power(
    effect_size=0.5, power=0.8, alpha=0.05
)
print(f"Need {n:.0f} per group")

# Power curve
import matplotlib.pyplot as plt
ns = range(10, 200)
powers = [analysis.power(effect_size=0.5, nobs1=n, alpha=0.05) for n in ns]
plt.plot(ns, powers); plt.axhline(0.8, ls='--'); plt.show()
Sources
  • Statistical Power Analysis for the Behavioral Sciences (2nd ed.), J. Cohen, Lawrence Erlbaum, 1988
  • K. S. Button et al., “Power Failure: Why Small Sample Size Undermines the Reliability of Neuroscience”, Nature Reviews Neuroscience 14, 2013
  • Trustworthy Online Controlled Experiments, R. Kohavi, D. Tang & Y. Xu, Cambridge University Press, 2020

Last reviewed October 2026 · How this site checks its content · Report a mistake

Check yourself

1. An A/B test was planned with 80% power to detect a 2-point lift. What does the 80% mean?

Show answer

C. Power is a property of the design: the probability of a significant result given an effect of the stated size. It says nothing about how likely the effect is to exist.

2. To detect an effect half as large with the same power and significance level, the sample size must be about…

Show answer

A. The standard error shrinks with √n, so halving the effect you want to see requires √n to double — four times the sample.

3. A small study finds a significant and surprisingly large effect. Why be cautious?

Show answer

A. Gelman & Carlin call this a Type M (magnitude) error: with low power, a significant estimate is often several times the true effect.

Linked from 3
← Previous
Effect Size & Practical Significance
Open in the full reader, with the topic sidebar