Bell Statistics

Two-sample t-test calculator

Work out how many observations each group needs before you run, then get the t statistic, p-value and confidence interval once the data is in. Welch's version is the default, because equal variances are an assumption you rarely have grounds for.

Allon Korem

Written by Allon Korem

Chief Executive Officer

Last updated

Calculator

The smallest difference worth detecting.

Pooled, from historical data.

n₂ ÷ n₁. 1 is an even split.

Required sample size
Per group100
Group 2100
Total200
Achieved powerAt the whole-number sample above.80.4%
Effect size (Cohen's d)0.400

Collect 200 observations in total and the test will detect a difference of 2.00 80.4% of the time, if a difference that large is really there. It says nothing about smaller differences, which this design will usually miss.

Sample size per group against statistical powerReaching 4.5% power takes 2 per group and 97.9% takes 200; the 80.0% target is met at 100.204060801001201401601802000%25%50%75%100%PowerSample size — per group80.0% → 100

Drag the dashed line — or focus it and use the arrow keys — to change the target power and resize the study.

Show these numbers as a table
Power at each sample size per group
PowerSample size
4.5%2
25.3%22
44.1%42
59.9%62
72.1%82
81.1%102
87.5%122
91.9%142
94.8%162
96.8%182
Required sample per group against difference in meansDetecting 0.25 takes 6,281 and 7.50 takes 9. At the 2.00 currently entered it is 100 — the requirement falls roughly as the square of the effect.101001,0001.002.003.004.005.006.007.00Difference in meansRequired sample per group (log scale)2.00 → 100

Drag the dashed line — or focus it and use the arrow keys — to change difference in means.

Show these numbers as a table
Required sample per group against difference in means
Difference in meansRequired sample per group
0.256,281
0.99399
1.74132
2.4865
3.2239
3.9726
4.7119
5.4615
6.2012
6.9410

When to use it

Use a two-sample t-test when you have one continuous measurement and two independent groups, and you want to know whether their averages differ by more than sampling noise would explain. Revenue per user in control against treatment, session length on two onboarding flows, delivery time from two warehouses — anything where each observation belongs to exactly one group and no observation is paired with another.

The independence requirement is the one that quietly fails in product work. If the same user appears in both arms, or the same user contributes several sessions, the observations are not independent and the test will report a p-value smaller than the evidence deserves. Repeated measurements on the same unit want the paired t-test or a model that accounts for the clustering; three or more groups want one-way ANOVA rather than a series of pairwise t-tests, which inflates the false-positive rate — see the problem of multiple comparisons.

If your outcome is a rate rather than a measurement — conversion, click-through, retention at day 7 — you want the A/B test sample size calculator instead. And if your question is "are these two groups the same?" rather than "do they differ?", a non-significant t-test does not answer it; an equivalence test does.

Assumptions

The t-test rests on three assumptions, and they are not equally fragile:

  • Independence, within and between groups. This is the assumption that matters. There is no correction to apply after the fact and no diagnostic plot that reveals it — it is a property of how you assigned units, not of the data you collected.
  • Approximate normality of the group means, not of the raw data. The Central Limit Theorem does most of the work here: with a few hundred observations per group, even visibly skewed data produces means that are near enough normal. Small samples of heavily skewed or long-tailed data are the real problem, and revenue per user is exactly that shape. See our note on what to do when data is not normally distributed, or use the Wilcoxon test if you would rather not assume it.
  • Equal variances — for Student's version only. Welch's version drops this assumption at a cost of a fraction of a degree of freedom, which is why it is the default here and the default in R. There is no good reason to run Student's t-test after a variance test; that two-step procedure has worse error rates than simply using Welch throughout.
  • Outliers are not an assumption, but they will dominate the result. A single extreme value can move both the mean and the standard deviation enough to flip a conclusion — see tackling outliers in A/B testing.

How the calculation works

The sample-size tab solves the exact non-central t power function, not the normal approximation. The approximation is off by a few percent at small n, which is precisely where the answer matters, and the exact version costs nothing to compute. Power is the probability that the test rejects when the true difference is the one you specified — so the number you get back is conditional on that difference being real, which is why the effect size you enter should be the smallest difference worth detecting rather than the one you hope to see.

Test statistic (Welch)
t = (x̄₁ − x̄₂) / √(s₁²/n₁ + s₂²/n₂)

Student's version replaces the denominator with the pooled standard error, sₚ√(1/n₁ + 1/n₂).

Degrees of freedom (Welch–Satterthwaite)
df = (s₁²/n₁ + s₂²/n₂)² / [ (s₁²/n₁)²/(n₁−1) + (s₂²/n₂)²/(n₂−1) ]

Non-integer, and lower than n₁ + n₂ − 2 whenever the variances differ. That is the price of dropping the equal-variance assumption, and it is small.

Effect size (Cohen's d)
d = (μ₁ − μ₂) / σ

The difference expressed in standard deviations. Sample size depends on the ratio, not on the two quantities separately: a 2-point difference with σ = 5 needs exactly the same n as a 0.4-point difference with σ = 1.

Power
1 − β = P( |T′| > t₁₋α/₂,df ), ncp = d·√(n₁n₂/(n₁+n₂))

T′ is non-central t with the stated non-centrality parameter. Achieved power is reported at the rounded-up n, so it is always at or slightly above the target you asked for.

Confidence interval
(x̄₁ − x̄₂) ± t₁₋α/₂,df · SE

The interval and the p-value always agree: the interval excludes zero exactly when p < α.

Worked example

You are testing a new checkout flow and the outcome is revenue per session. Historical sessions average $10.00 with a standard deviation of $5.00, and the smallest improvement that would justify shipping the change is $2.00. You want 80% power at the conventional 5% two-sided significance level, with traffic split evenly.

Significance level (α)
0.05, two-sided
Power (1 − β)
0.80
Mean, control
10.00
Mean, treatment
12.00
Standard deviation
5.00
Allocation ratio
1:1

100 sessions per group, 200 in total. Cohen's d is 0.40 and achieved power at n = 100 is 80.4%.

Two hundred sessions is the cost of being able to detect a $2.00 lift four times out of five. It is not the number that guarantees you will see one: if the true lift is $1.00 rather than $2.00, this design has about 29% power, and the most likely outcome is an inconclusive test that gets read as "no effect". Halving the detectable difference roughly quadruples the sample size, which is the single most useful thing to know before negotiating a test's scope.

Interpreting the output

The p-value is the probability of seeing a difference at least this large if the two groups genuinely had the same mean. It is not the probability that the null hypothesis is true, and it is not the probability that the result will replicate. A p of 0.03 says the data would be somewhat surprising under no effect; it says nothing about how large the effect is.

Read the confidence interval first. It carries everything the p-value carries — it excludes zero exactly when p < α — and it also tells you the range of differences the data is consistent with. An interval of [$0.10, $4.20] is technically significant and practically useless: it cannot distinguish a trivial lift from a transformative one. An interval of [−$0.20, $0.30] is not significant, but it is genuinely informative, because it rules out anything worth acting on. Reporting the interval rather than the p-value alone is the main recommendation in our guide to reporting A/B test results properly.

A non-significant result is not evidence of no difference. If you need to demonstrate that two options are interchangeable — that a cheaper vendor performs no worse, that a refactor changed nothing — the t-test is the wrong instrument. Use an equivalence test to show the difference falls inside a margin you nominate in advance, or a non-inferiority test if only one direction concerns you.

Finally, the power you calculated before the test tells you nothing new after it. Post-hoc power computed from the observed effect is a deterministic function of the p-value and adds no information; if the test was inconclusive, the useful question is what the confidence interval rules out, not what the power "was".

Frequently asked questions

Should I use Welch's t-test or Student's t-test?
Welch, essentially always. It does not assume the two groups have equal variances, and when they happen to be equal it costs almost nothing — a fraction of a degree of freedom. The common practice of running a variance test first and choosing between the two based on the result produces worse error rates than simply using Welch throughout, because the choice is itself made from the data. R has defaulted to Welch for this reason for decades.
Can I use a one-tailed test to reduce the sample size?
You can, and it reduces the required n by roughly 20% at conventional settings — but only if you would genuinely take no action on a result in the opposite direction, and only if you decide that before seeing any data. Switching to one-tailed after a two-tailed test disappoints is a way of manufacturing significance, not of finding it. We wrote about the trade-off in detail in one-tailed vs two-tailed tests.
I don't know the standard deviation yet. What do I put in?
Take it from historical data on the same metric and the same population — the previous month of the same funnel step is usually the best available estimate. If you have nothing, run a short pilot and use its standard deviation, or express the difference you care about in standard deviations directly (Cohen's d) and set the standard deviation to 1. What you should not do is guess low: the required sample size scales with the square of the standard deviation, so a 30% underestimate leaves you with about half the power you planned for.
Does an uneven split between groups cost me anything?
Yes, and more than most people expect. A 1:1 split is optimal when the two groups have similar variances. A 2:1 split needs about 12% more total observations for the same power, and a 4:1 split about 56% more. Uneven allocation is sometimes worth it — limiting exposure to a risky change, or reusing a large existing control group — but it should be a deliberate trade, not a default.
My data is skewed. Is the t-test still valid?
Usually, provided the groups are reasonably large. The test assumes the sampling distribution of the mean is approximately normal, not that the data is, and with a few hundred observations per group the Central Limit Theorem delivers that even for visibly skewed distributions. The genuine problem cases are small samples of very long-tailed data — revenue per user with a handful of whales is the classic example — where a few observations dominate both the mean and the variance. There, either use the Wilcoxon test, analyse a transformed or winsorised outcome, or bootstrap the interval.
My result is significant but the difference looks tiny. What now?
That is what a large sample buys you: the ability to detect differences too small to matter. Statistical significance answers "is it distinguishable from zero?", not "is it worth shipping?". Compare the confidence interval against the smallest difference that would change your decision — the one you should have nominated before running the test. If the whole interval sits below it, you have a real but immaterial effect, and the correct conclusion is to ship or not on other grounds.

Related calculators

  • Paired t-test

    Before-and-after or matched pairs — size the study on the difference SD, then test it.

  • One-way ANOVA

    Three or more independent groups on one continuous outcome — size it, then run the F test.

  • Wilcoxon test

    Rank-sum (Mann-Whitney) and signed-rank tests, with the exact distribution for small samples.

  • Equivalence: two means

    Show two averages are close enough to be interchangeable — set the margin, size the study, run both one-sided tests.

Terms on this page

  • A/B testing

    A randomised experiment on live traffic — and randomisation is the only part that makes it causal.

  • Randomization

    The one mechanism that makes a comparison causal — and the four ways it silently fails.

  • Sample size

    Four inputs, one number, fixed before the test runs — and the square law that makes small effects expensive.

  • Minimum detectable effect

    The smallest lift you designed to catch — a business decision that gets outsourced to statistics.

  • Sequential testing

    How to look at a running test without breaking it — and what peeking costs when you do not.

  • CUPED

    Use pre-period data to strip out noise — the same test, 20-50% less traffic, no change to the estimate.

  • P-value

    How surprising your data would be if there were no effect — and the four things it is constantly mistaken for.

  • Statistical significance

    A verdict about evidence, not about importance — and the difference is where most bad decisions live.

  • Significance level

    The false-positive rate you agree to in advance — a budget, and one most teams overspend.

  • Null hypothesis

    The assumption every test argues against, and the reason you can never prove two things are the same.

  • Confidence interval

    The range your data can actually support, and why it answers the business question a p-value cannot.

  • Statistical power

    The probability your test finds a real effect — and why most tests that report nothing were never able to.

  • Type II error

    The false negative — invisible by nature, which is why nobody counts how many good ideas it kills.

  • Effect size

    How big the difference is — the number a p-value throws away and a business case runs on.

  • Causal inference

    Estimating what an action caused by reconstructing what would have happened without it.

  • Incrementality

    The conversions that would not have happened anyway — and the gap between that and what platforms report.

  • Confounding variable

    A common cause of both variables — the reason a strong, stable correlation can mean nothing.

  • Selection bias

    When who ends up in the data is not who you meant to study — and more data makes it worse.

  • Difference-in-differences

    Subtract the untreated group's change from the treated group's — and everything rests on parallel trends.

  • Synthetic control

    Build the comparison group instead of finding one — the method for when you have one treated unit.

  • Geo experiment

    Randomise regions instead of users — the way to test marketing that cannot be hidden from a person.

  • Propensity score matching

    Pair like with like on the probability of being treated — and hope nothing important went unmeasured.

  • Marketing mix modelling

    One regression across every channel, built on aggregate data — no tracking, and strong assumptions.

  • Regression analysis

    Fit a line through the data — and the phrase 'holding everything else fixed' is where the trouble starts.

  • Correlation

    How tightly two variables move together — bounded, unitless, and silent about cause.

  • R-squared

    Share of variance explained — the most quoted and most over-interpreted number in any model output.

  • Multicollinearity

    When predictors move together the model cannot separate them — good predictions, meaningless coefficients.

  • Adstock

    Advertising does not stop working the week it stops running — and this is how models say so.

  • Diminishing returns

    The tenth million does less than the first — and why average ROAS is the wrong number to budget on.

  • Overfitting

    A model that memorised the noise — excellent on the data it saw, useless on the data it will meet.

  • Standard deviation

    How spread out the data are, in the data's own units — and the reason some metrics need vastly more sample.

  • Variance

    Spread in squared units — awkward to read, and the quantity every sample-size formula is built on.

  • Standard error

    How much your estimate would move if you ran the study again — precision, not spread.

  • Normal distribution

    The bell curve — and why your skewed revenue data usually does not break the test anyway.

  • Central limit theorem

    Why averages go bell-shaped even when the data do not — the result that makes ordinary tests work.

  • Outlier

    The extreme value that decides your result — and why the rule for handling it must precede the data.

Talk to the people who build these for a living

We design and run experiments where the sample size, the metric and the decision rule are agreed before anyone looks at the data. A/B Testing

References