A/B Test Calculator: Sample Size and Significance
This calculator does two jobs for an A/B test. Before the test, it tells you how many users each variant needs. After the test, it tells you whether the difference you measured is bigger than chance. It handles both kinds of metric:
- A yes/no rate such as signups or purchases: the first two calculators (z-test).
- An average per user such as revenue, orders, sessions or time on page: the last two calculators (t-test).
Everything runs in your browser, so nothing you type is sent anywhere. The same numbers come from statsmodels and SciPy in Python, and the code is further down the page.
Sample Size Calculator for Conversion Rates
Fill in the conversion rate you have today and the smallest lift worth detecting. The result is the number of users in the control group (the treatment group is sized by the traffic split).
The defaults are an 8% baseline and a 12.5% relative lift, which is 8% to 9%. The result is 12,199 users per group, the same number the sample size post gets with statsmodels.
Significance Calculator for Conversion Rates
Enter what each variant saw. The test is a two-sided two-proportion z-test of B against A, with a confidence interval for the difference.
With the defaults, A converts at 8.00% and B at 9.00%, a gap of 1 percentage point. The p-value is 0.0112 and the 95% interval for the difference runs from 0.23 to 1.77 points, so the lift is significant. A p-value tells you whether the gap is bigger than chance. The interval tells you how big it could plausibly be, so read both.
Sample Size Calculator for Averages
Use this when the metric is a number per user, such as revenue per visitor, orders per customer or minutes on the page. Besides the effect you want to detect, you need the standard deviation of the metric per user, which comes from past data (STDDEV in SQL or .std() in pandas). The result is the number of users in the control group.
The defaults are revenue per user of $24.10 with a standard deviation of $41 and a 5% relative lift (about $1.21). That needs 18,175 users per group, which is what TTestIndPower returns for the same inputs. Revenue has a standard deviation well above its mean, so averages need far more users than the lift sounds like. Halving the standard deviation, for example with CUPED, cuts the sample to a quarter.
Significance Calculator for Averages
Enter the number of users, the average and the standard deviation for each variant. The test is a two-sided Welch's t-test of B against A, which does not assume the two groups have the same variance. If you only have totals, the average is the sum divided by the users, and the standard deviation needs the sum of squares too: sqrt(sum_sq / n - mean^2), or just ask your database for STDDEV.
With the defaults, A averages $24.10 and B $25.60, a gap of $1.50 (6.2%). The p-value is 0.0743 and the 95% interval for the difference runs from -$0.15 to $3.15, so this is not significant even though the lift looks healthy. The interval is the useful part: the true gain could be anywhere from a small loss to about $3. Seeing a $1.50 difference reliably, with a standard deviation near $42, takes about 12,300 users per group, more than twice the 5,000 here.
What the calculator does
- Sample size uses Cohen's h, the arcsine effect size for two proportions:
h = 2*asin(sqrt(p_target)) - 2*asin(sqrt(p_baseline)). It then finds the smallest control group where a two-sample z-test has the power you asked for. For a split that is not 50/50, the treatment group is the control group times the ratio of the two shares. - Significance is a z-test that pools the two conversion rates for the standard error, which is what
proportions_ztestin statsmodels does. The interval is the unpooled Wald interval for the difference,(p_B - p_A) ± z * sqrt(p_A(1-p_A)/n_A + p_B(1-p_B)/n_B). It is the textbook normal approximation, which is fine at the sample sizes A/B tests usually have. Use Wilson or Newcombe intervals, or Fisher's exact test, when counts are very small or a rate is close to 0% or 100%. - Sample size for averages uses Cohen's d, the difference divided by the standard deviation, and the power of a two-sample t-test (the noncentral t distribution), as
TTestIndPowerin statsmodels does. It is exact where the proportion version is a normal approximation, so it is also right for small samples. - Significance for averages is Welch's t-test: the standard error is
sqrt(sd_A²/n_A + sd_B²/n_B)and the degrees of freedom come from the Welch-Satterthwaite formula, so the two groups can have different spreads and sizes. The interval is the difference plus or minus a t quantile times that standard error. It matchesscipy.stats.ttest_ind(..., equal_var=False). - The sample ratio check is a chi-square test of the visitor counts against the traffic split you planned. A tiny p-value (below 0.001 here) means users are not being assigned the way you think, and the test result cannot be trusted until that is fixed. The sample ratio mismatch post covers the causes.
The same calculations in Python
import numpy as np
from statsmodels.stats.power import NormalIndPower
from statsmodels.stats.proportion import confint_proportions_2indep, proportion_effectsize, proportions_ztest
# Sample size: 8% to 9%, alpha 0.05, power 80%, 50/50 split
h = proportion_effectsize(0.09, 0.08)
n = NormalIndPower().solve_power(effect_size=h, alpha=0.05, power=0.8, ratio=1.0)
print(int(np.ceil(n))) # 12199 users per group
# Significance: A converted 800 of 10,000, B converted 900 of 10,000
z, p = proportions_ztest([900, 800], [10000, 10000])
lo, hi = confint_proportions_2indep(900, 10000, 800, 10000, method="wald")
print(f"p = {p:.4f}, difference CI = {lo * 100:.2f} to {hi * 100:.2f} points")
# Averages, sample size: revenue per user $24.10, sd $41, detect +5% (about $1.205)
from statsmodels.stats.power import TTestIndPower
d = 24.1 * 0.05 / 41
n = TTestIndPower().solve_power(effect_size=d, alpha=0.05, power=0.8)
print(int(np.ceil(n))) # 18175 users per group
# Averages, significance: Welch's t-test from summary statistics
from scipy.stats import ttest_ind_from_stats
res = ttest_ind_from_stats(25.6, 43, 5000, 24.1, 41, 5000, equal_var=False)
print(f"t = {res.statistic:.3f}, p = {res.pvalue:.4f}") # t = 1.785, p = 0.0743
The sample size and power post explains each argument and plots power curves, and the A/B test analysis post runs the test on a full simulated experiment.
Before you trust the answer
- Pick the sample size before you start and stop when you reach it. Checking the p-value every day and stopping at the first significant result produces false positives far more often than the 5% you set. If you need to look early, use a sequential test.
- Choose the minimum detectable effect from the business. Sizing the test for a lift too small to matter wastes weeks, and a lift you cannot afford to miss needs more users than a bigger one. Halving the effect roughly quadruples the sample size.
- Run whole weeks. Weekday and weekend behavior differ, so round the duration up to complete weeks.
- Testing several variants or metrics? Each extra comparison raises the chance of a false positive. See multiple testing.
- Revenue and other skewed metrics. The t-test compares averages, and a few very large orders can dominate the standard deviation. With thousands of users per group the test is still reliable, but check for outliers, and consider capping extreme values before you run it.
- Ratios such as revenue per session are not an average over independent users, so neither calculator fits. Use the delta method or a bootstrap.
- The A/B testing guide lists the whole workflow.
Last updated: Dec 06, 2026