Tools A/B test sample size calculator

A/B test sample size calculator

The formula was read from Evan Miller's own JavaScript, then re-implemented in Node and checked cell by cell. Every quote carries its publisher and read-date.

The short answer

At a 3% conversion rate, detecting a 10% lift takes 51,487 visitors per variation. On a two-arm test at 1,000 sessions a day, that's 103 days. The number decides whether you can run the test at all, and no tool changes it. Get yours below. Then read on, because the sample size is a floor rather than a schedule, and if your answer is a year, the right move is to test something else.

The calculator

Sample size per variation

No email, no sign-in. Recalculates as you type.

The control's current rate for the metric you'll judge on, over a window that looks like the test window.

How the effect is expressed

The smallest lift you'd act on — not the lift you expect.

+10% relative on a 3.0% baseline = 3.30%, a gain of 0.30 percentage points.

Traffic scales linearly with this.

How often you'd call a difference real when there isn't one.

How often you'd detect a true effect this size.

Hypothesis

One-sided saves ~21% and gives up detecting that the variant made things worse.

Drives the duration output.

51,487

visitors per variation

Total, across all 2 arms
102,974
What you'd be detecting
3.00% → 3.30%

Add sessions per day to get a duration.

Fixed-horizon frequentist, two-proportion z-test in Evan Miller's unpooled form — the null variance uses the baseline rate, not the midpoint of the two rates. Rounded up, so expect one visitor more than his page shows.

Two inputs to set deliberately. Power is the one most calculators hide, and under-powering is the silent failure: the test runs, shows nothing, the team concludes “no difference.” And check whether the minimum detectable effect is relative or absolute — Evan Miller's calculator defaults to absolute, Optimizely's is labelled relative (both read 26 July 2026), and confusing the two puts you out by an order of magnitude at low baselines. On a 3.0% baseline, +10% relative means 3.30%: a gain of 0.30 percentage points.

The formula, and how it was verified

The literal contents of evanmiller.org/ab-testing/sample-size-fixed.js, fetched 26 July 2026:

function num_subjects(alpha, power_level, p, delta) {
    if (p > 0.5) {
        p = 1.0 - p;
    }
    var t_alpha2 = ppnd(1.0-alpha/2);
    var t_beta   = ppnd(power_level);

    var sd1 = Math.sqrt(2 * p * (1.0 - p));
    var sd2 = Math.sqrt(p * (1.0 - p) + (p + delta) * (1.0 - p - delta));

    return (t_alpha2 * sd1 + t_beta * sd2) * (t_alpha2 * sd1 + t_beta * sd2) / (delta * delta);
}
n per variation = [ z₁₋α/₂ · √(2p(1−p)) + z₁₋β · √( p(1−p) + (p+δ)(1−p−δ) ) ]² ÷ δ²

p is the baseline as a proportion. δ is the absolute effect — compute it from the original baseline (δ = p × relativeMDE) before calling the function, because the p > 0.5 line folds the baseline onto its complement. ppnd is the inverse normal CDF. For one-sided, pass 1 − α instead of 1 − α/2. Round up. His published defaults, from defaults.js in the same fetch: alpha_level = 0.05, power_level = 0.80, one_sided = false, mde_is_relative = 0.

How it was checked. Re-implemented in Node against Evan Miller's own default state (p = 20%, δ = 0.05 absolute, α = 0.05, power = 0.80): 1030.22 raw. His page rounds and displays 1,030; this calculator rounds up to 1,031, because you cannot recruit a fraction of a visitor and rounding down under-powers the test. Expect our numbers to sit one visitor above his. Then reconciled against the standard pooled two-proportion form, which uses the midpoint p̄ = (p₁+p₂)/2 as the null variance rather than the baseline:

Evan Miller's form against the pooled midpoint form, per variation
Baseline · relative MDE Evan Miller Pooled midpoint Divergence
3% · +10% 51,487 53,211 3.3%
3% · +20% 13,051 13,914 6.6%
5% · +10% 30,245 31,234 3.3%
10% · +10% 14,313 14,751 3.1%
1% · +50% 6,659 7,750 16.4%

Both are defensible. This calculator ships Evan Miller's form; know the spread before you argue with someone else's number.

One more source of confusion: the formula in NIST's e-Handbook §7.2.4.2 is one-sample — a proportion against a fixed target, not two arms against each other — and it drops the two-arm √2 factor. Plenty of blog posts cite it as the A/B formula.

If you test on Optimizely or VWO, use their calculator, not this one. Optimizely's Stats Engine and VWO's enhanced SmartStats are both sequential, and a fixed-horizon number doesn't describe what a sequential engine will do with your data. Both vendors also ship a fixed-horizon mode — Optimizely lists “Frequentist (Fixed Horizon)” alongside Bayesian and Stats Engine, in beta as of 28 July 2026, and VWO's own duration calculator recommends one: “For accurate, error-free results, use the Fixed horizon approach, which only calculates statistics after the full sample size is reached.” If that's what you're running, this number applies. One footnote on Optimizely's own tool: it has no power input at all, and its FAQ carries the heading “Where is statistical power in your sample size calculator?”

How much traffic, and how long

Per variation, α = 0.05 two-sided, 80% power. Computed 26 July 2026 from the formula above.

Visitors needed per variation, by baseline conversion rate and relative minimum detectable effect
Baseline ↓ / Relative MDE → +2% +5% +10% +20% +50%
1% 3,896,727 626,231 157,697 39,986 6,659
2% 1,928,623 309,928 78,040 19,785 3,293
3% 1,272,588 204,494 51,487 13,051 2,171
5% 747,760 120,146 30,245 7,664 1,273
10% 354,139 56,886 14,313 3,623 600
20% 157,329 25,256 6,348 1,603 263
40% 58,924 9,440 2,365 593 95

The columns move faster than the rows because cost is quadratic in the effect. Kohavi, Tang, Xu, Hemkens and Ioannidis, Trials 21:150 (2020): “Because the relationship between the detectable effect and the number of users needed is quadratic, the ability to detect an effect twice as small, e.g., 0.25%, requires quadrupling the number of users.”

As a calendar — two arms, 3% baseline, +10% target, all traffic in the test:

Days to reach 51,487 per variation on a two-arm test, by daily sessions
Sessions/day Days to reach the sample size Run length, at a two-week minimum
1,000 103 105
3,000 35 35
10,000 11 14
30,000 4 14
100,000 2 14

That second column exists because two minimums have nothing to do with sample size. Run whole weeks: shopping has a weekly rhythm, and VWO's duration calculator says so directly — “It is recommended to run your campaigns for at least 7 days to capture natural fluctuations in metric performance across weekdays and weekends” (read 26 July 2026). And run at least two, per Kohavi, Deng, Longbotham and Xu in Seven Rules of Thumb for Web Site Experimenters (KDD 2014), on novelty: “we recommend running experiments for two weeks and looking for such effects.” If your business has a monthly rhythm — payday, a subscription cycle, a Friday drop — run through one.

Longer is not automatically safer. The same authors' 2020 paper puts the final read at “usually based on 1–2 weeks of data.” A fourteen-week requirement is not a fourteen-week test. It's a test you shouldn't run.

totalRequired  = nPerVariation × variations
dailyEntrants  = sessionsPerDay × (allocation ÷ 100)
days           = ceil(totalRequired ÷ dailyEntrants)
runLengthDays  = max(14, ceil(days ÷ 7) × 7)

Why you can't stop when the number looks good

Everything above assumes the sample size was fixed before the test started. Check daily and stop the moment it turns green, and you're running a different experiment from the one the maths describes.

Evan Miller simulated it in How Not To Run An A/B Test (read 26 July 2026): a 50% baseline, no real effect, testing after every observation, stopping at 5% significance or 150 observations. The true false-positive rate came out at 26.1%“more than five times what you probably thought the significance level was.” To hold a real 5% while looking repeatedly, you have to report at a much tighter threshold:

The significance threshold you must report at, by how many times you peek
Times you peek Threshold you must report at
1 2.9%
2 2.2%
3 1.8%
5 1.4%
10 1.0%

His fix: “Decide on a sample size in advance and wait until the experiment is over before you start believing the ‘chance of beating original’ figures that the A/B testing software gives you.”

The qualification most pages skip: this is a fixed-horizon frequentist problem. Sequential and Bayesian engines are built precisely so you can look — that is what Optimizely's Stats Engine and VWO's SmartStats are for. Know which you're running on before you take “never peek” as gospel.

The practical fix is to take the decision away from yourself. A Mtrix experiment carries a completion trigger — a visitor count, a date, or a revenue threshold — set when you create it. Put the number from the calculator into the visitor count and stopping stops being a 9pm judgement call. See how experiments are set up.

Mtrix's own reports sit in the second camp: probability-to-be-best is computed with a sequential method built to be monitored while the test runs, the same class as Stats Engine and SmartStats. Watching a Mtrix report mid-test doesn't corrupt it — the trigger is a finish line, not a blindfold.

Revenue per visitor is the expensive metric

Sample-size formulas for conversion rate assume a binary outcome. Revenue per visitor isn't binary and it's violently skewed — one £900 order sits in the same average as four hundred visitors who bought nothing. Skew slows the average's convergence to normality, and Kohavi's Seven Rules puts a number on it (Rule #7, Have Enough Users): the mean needs roughly 355 × s² observations per variant before it is approximately normal, where s is the skewness coefficient. Their Bing table:

Kohavi's Rule #7 table: skewness, sample size and sensitivity by metric, at Bing
Metric |Skewness| Sample size Sensitivity at 80% power
Revenue/User 17.9 114k 4.4%
Revenue/User (capped) 5.2 9.7k 10.5%
Sessions/User 3.6 4.70k 5.4%
Time To Success 2.1 1.55k 12.3%

Read that third column for what it is: where each metric's average starts behaving normally, not a power calculation. On an equally-sized 50/50 split — what this calculator assumes — the paper says plainly that “Power calculations will typically provide the lower bound for sample size.” What the table shows is the price of skew, because that floor scales with s². Capping is the paper's own mitigation: after capping revenue per user at $10 per user per week, “For the same sample size, Capped Revenue per user can detect a change 30% smaller than Revenue per user.” And, verbatim: “At a commerce site, the skewness for purchases/customer was >10 and for revenue/customer >30.”

For a DTC store: decide the test on conversion rate or add-to-cart rate, and read revenue per visitor as the check that the answer was worth having. Mtrix reports all three on the same experiment, so you don't pick one at setup time.

The skewness figures in that table were corrected to 17.9 and 5.2 in January 2015; the paper's prose still carries the original 18.2 and 5.3.

When the number is bigger than your traffic

This is the real question behind most sample-size searches, and it deserves a straight answer rather than a smaller number.

First, the reframe. Kohavi 2020: “About two-thirds of experiments show that promising ideas that we implemented in products failed to improve the metrics they were designed to change, and this was worse in well-optimized domains such as the search engines, where failures were in the range of 80–90%.” The alternative to testing isn't shipping faster. It's shipping wrong, two times in three. Seven Rules is blunt about the size of real wins, at Bing scale: “For web sites like Bing, where thousands of experiments are being run annually, most fail, and those that succeed improve key metrics by 0.1% to 1.0%, once diluted to overall impact.” Your store isn't Bing, and a first pass at an unoptimised page can beat that. But price a 1% target against the grid above before you plan it.

So change the test, not the statistics.

Six levers when the sample size is bigger than your traffic
Lever What it buys What it costs
Test a bigger change Sample scales with 1/MDE². Moving the target from +5% to +20% on a 3% baseline drops 204,494 → 13,051 per arm, about 16×. You stop learning from refinements. Redesign the page; don't move the button.
Test higher in the funnel Add-to-cart at a 12% baseline needs 11,658 per arm against 78,040 for purchase at 2% — roughly 7× less at the same relative MDE. It's a proxy: add-to-cart can rise while orders don't. And add-to-cart rate is measured four different ways, so pick the denominator deliberately.
Run two arms, not five Total is per-variation × arms. A/B/C/D costs twice what A/B costs. Fewer ideas per cycle.
Drop significance to 90% 51,487 → 40,630 per arm, a 21% saving. You double your false-positive rate. Fine for a reversible layout change. Not for pricing.
Shift traffic to the leader as you go A multi-armed bandit moves traffic toward the winning arm, so being undecided costs less revenue. It optimises for earning, not learning. The effect estimate comes out less clean.
Stop testing and start looking Session replay, click and scroll maps and error tracking need no statistical power at all. One recording of a checkout failing on iOS beats an underpowered twelve-week test. It's diagnosis, not proof. You'll be acting on judgement.

That last row is where most brands under a thousand orders a month should spend their effort, and capture rate is what makes it work. Mtrix records 100% of sessions — sampling is an opt-in control, not a plan tier — and replay filters by experiment and by variant arm, so when a test does finish you can open the sessions from the losing arm and watch what went wrong. See session replay. Two caveats in writing: replay and error data are kept one month, so a fourteen-week test outlives its own recordings; and Mtrix doesn't run your experimentation programme for you.

The verdict, including the part that costs us the sale. Below roughly a thousand orders a month, most A/B tests you'd want to run cannot conclude inside a quarter. That's not a reason to guess. It's a reason to change what you measure: test changes big enough to matter, judge them on a metric high enough in the funnel to move, and spend the rest of your attention on what actually breaks. If your constraint today is budget rather than capability, Microsoft Clarity is genuinely free, with no traffic ceiling and no card, and it's the honest place to start. Know one limit going in: its playback data is deleted at 30 days (Microsoft's own data-retention doc, read 26 July 2026). Mtrix runs a one-month trial, not a free tier, and it's priced for brands where a percentage point of conversion outweighs the subscription.

Frequently asked questions

How long should an A/B test run?
Long enough to reach the sample size, and never fewer than two whole weeks. VWO recommends at least seven days to capture weekday and weekend behaviour; Kohavi and co-authors recommend two weeks so novelty effects have time to decay. Run whole weeks, and run through your own business cycle if you have one.
Is the sample size per variation or in total?
Per variation. 51,487 for a two-arm test means 102,974 visitors in total, and 205,948 if you add two more variants. This is the most common way sample-size estimates get misread, and it's wrong by 2–4×.
Can I stop an A/B test early once it hits significance?
Not under a fixed-horizon frequentist analysis. Evan Miller's simulation of a no-effect test checked after every observation reached a 26.1% false-positive rate against a nominal 5%. If your platform runs a sequential or Bayesian engine — Optimizely's Stats Engine, VWO's SmartStats — it's designed to be monitored and the rule doesn't apply. Check which you're on first.
One-tailed or two-tailed?
Two-tailed, in almost every ecommerce case. One-tailed at 95% needs the same sample as two-tailed at 90% — a real 21% saving at a 3% baseline — but it buys that by giving up the ability to detect that your variant made things worse. When shipping a loser costs revenue directly, that's the wrong trade.
Why does this give a different number from Optimizely's or VWO's?
They aren't computing the same object. This is fixed-horizon frequentist, using Evan Miller's formulation; Optimizely's Stats Engine and VWO's SmartStats are sequential. And even among fixed-horizon calculators there's a legitimate 3–16% spread, depending on whether the null variance uses the baseline rate or the midpoint of the two rates.
How much traffic do I need to test revenue per visitor?
More than for conversion rate, and the gap is wide. Revenue per visitor is heavily skewed — Kohavi reports skewness above 30 for revenue per customer at a commerce site — and the more skewed a metric is, the more observations its average needs before it behaves normally, which is the precondition the sample-size maths assumes in the first place. Decide on conversion rate; sanity-check on revenue.

Plan the test, then run it without arguing about when to stop

Set the sample size as the finish line when you create the experiment, run every test to it, and read conversion rate, add-to-cart rate and revenue per visitor on the same report.

Ada Kern Experimentation & analytics Writes about experimentation and analytics at Mtrix, and about what a test result does and does not justify.
Build with Mtrix