Most "can we ship the cheaper option?" decisions are one-sided: the new thing has to not be worse, and nobody will complain if it turns out better. This calculator plans and reads that test — a margin you are willing to give away, a one-sided p-value, and the confidence bound the claim rests on.
Which way is bad. On a retention rate “worse” means lower; on an error rate or a load time it means higher. The same two numbers support opposite conclusions under the two readings, and nothing in the output reveals a wrong choice, so there is no safe default — set this before anything else.
Says what “worse” means. There is no safe default.
How much worse group 1 is allowed to be and still be acceptable, as a magnitude in your own units — the direction above decides which way that points. Choose it for what the loss would cost at your volume, and before the data.
A magnitude. The direction above points it.
What you actually expect the gap to be. What gets powered is the room between this and the margin, not the margin itself, so an assumed difference that eats into the margin costs sample size very quickly. If you privately expect the new option to be slightly worse, say so here rather than in a footnote.
Group 1 − group 2. 0 assumes exact parity.
How much individual values scatter within a group. The sample scales with its square, so the design is really driven by the margin measured in standard deviations — take this from history rather than optimism.
Pooled, from historical data.
n₂ ÷ n₁ — how the sample is divided between the two groups. An even split (1) buys the most power per observation. A larger ratio puts more in the second group, which is worth doing when one arm is cheaper or riskier to fill, and needs a bigger total for the same power.
n₂ ÷ n₁. 1 is an even split.
One-sided, because the question only has one side: nothing above the margin counts against the new option. 0.05 is usual in product work; trials and regulators generally expect 0.025, which is the level that lines up with a two-sided 95% interval.
One-sided. 0.05 in product work, 0.025 in trials.
The chance the test finds the effect if the effect is really there. At 0.80 you miss a real one in one study out of five; 0.90 is the usual choice when a miss is the expensive outcome, and costs roughly a third more data. Power is a property of the design — it cannot be recovered after the data is in.
Required sample size for non-inferiority
Per group
38,778
Group 2
38,778
Total
77,556
Achieved powerAt the whole-number sample above.
80.0%
Textbook closed form, per group(z₁₋ₐ + z₁₋ᵦ)²σ²(1 + 1/k) ÷ Δ², with normal critical values. A lower bound on the exact answer above.
38,777
Room to the marginThe distance the study has to work with.
0.2500
Assumed true difference
0
Collect 77,556 observations in total and the study will conclude that group 1 is not more than 0.250 *below* group 2 80.0% of the time, if the truth is what you assumed. What is being powered is the 0.250 of room between that assumption and the margin — not the margin itself — so an assumed difference that eats into the margin costs sample size very quickly. If you privately expect the new option to be slightly worse, say so in the field above rather than planning against exact parity.
Sized for a test that group 1 is not more than the margin *below* group 2, with higher values the better outcome.
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
Power
Sample size
5.1%
2
26.4%
6,462
41.7%
12,922
54.5%
19,382
65.0%
25,842
73.4%
32,302
80.0%
38,762
85.1%
45,222
89.0%
51,682
91.9%
58,142
94.1%
64,602
95.7%
71,062
96.9%
77,522
Drag the dashed line — or focus it and use the arrow keys — to change non-inferiority margin.
Show these numbers as a table
Required sample per group against non-inferiority margin
Non-inferiority margin
Required sample per group
0.0700
494,606
0.924
2,838
1.78
767
2.63
351
3.49
200
4.34
130
5.20
91
6.05
67
6.90
52
7.76
41
Which way is bad. On a retention rate “worse” means lower; on an error rate or a load time it means higher. The same two numbers support opposite conclusions under the two readings, and nothing in the output reveals a wrong choice, so there is no safe default — set this before anything else.
Says what “worse” means. There is no safe default.
The margin fixed before the data, in your own units. Renegotiating it now that the bound is visible is the one move this test cannot survive — the bound was computed to be compared against a number chosen independently of it.
The one you agreed before the data landed.
How many independent observations group 1's summary came from. Group 1 is the side being defended: the new option, the cheaper path, the simplification.
The same count for the incumbent. If it dwarfs group 1 — a pilot against all existing traffic — the confidence bound is set almost entirely by the smaller arm.
Group 1's observed average, in the same units as the margin. Which group goes where matters more here than in an ordinary comparison: the question is one-directional, so swapping the two asks a different question and can answer it confidently.
The new or cheaper option.
The incumbent's observed average — the benchmark group 1 must not fall meaningfully below (or rise above, if lower is better).
The incumbent it must not be worse than.
Group 1's sample standard deviation — the spread of individual values, not the standard error of the mean.
The incumbent's sample standard deviation. A spread well above what you designed against widens the bound, and non-inferiority can then fail for reasons unrelated to the means.
One-sided, because the question only has one side: nothing above the margin counts against the new option. 0.05 is usual in product work; trials and regulators generally expect 0.025, which is the level that lines up with a two-sided 95% interval.
One-sided.
Welch does not assume the two groups have the same spread, and costs almost nothing when they do — which is why it is the default here and in R. Student's pooled version is marginally more powerful under equal variances and is misleading when they differ, badly so if the groups are also unequal in size.
Welch unless you have a reason.
Non-inferiority test result
One-sided p-value
0.0171
Non-inferior at Δ = 0.250
Yes
One-sided 95.0% lower boundThe number the decision actually rests on.
-0.2120
Two-sided 90% interval
[-0.212, 0.052]
Difference in meansGroup 1 − group 2. The best guess at the real cost.
-0.08000
t
2.1183
Degrees of freedom
119973.16
Standard error
0.08025
Higher is better here, so the question is whether group 1 can be ruled out as being more than 0.250 *below* group 2. The one-sided 95.0% lower bound on the difference is -0.212, against a margin of −0.250 — it clears, so non-inferiority is established (one-sided p 0.0171). Note what that does and does not say: the best estimate of the real difference is still -0.0800, and the test has bounded the worst case the data allow rather than shown the two are the same. Multiply that point estimate by your annual volume before treating the change as free.
Tested as: group 1 is not more than 0.2500 *below* group 2, with higher values the better outcome. Non-inferiority holds when the lower 95.0% bound stays above −0.2500.
The pair of endpoints shown is the two-sided 90% interval; the lower one is the one-sided bound the test uses, and the other end is only there because a table with an infinity in it is unreadable.
Drag either dashed line — or focus it and use the arrow keys — to change non-inferiority margin.
Show these numbers as a table
The interval on the difference, against the non-inferiority margin
Difference in means
Estimate
Interval
Group 1 − group 2
-0.0800
-0.212 to 0.0520
When to use it
Use a non-inferiority test when the change is worth making for reasons outside the metric, and the metric's job is only to confirm you are not paying too much for it. A recommendation model that costs a tenth as much to serve; a support process that frees three people. The case for shipping is already made, and the experiment exists to bound the damage: the question is not "is it better?" but "how confident am I that it is not worse by more than Δ?".
The trap is reaching for a two-sample t-test and reading a non-significant result as permission. It is not: p > 0.05 means the data did not distinguish the arms, which is also what a test that was too small or too noisy produces. The incentives make it worse than the average inference error, because the team wants to ship and an inconclusive test looks like a green light. Reframing so that shipping requires positive evidence is the point, argued in when being good enough is enough.
Choose non-inferiority over an equivalence test when a surprise in the good direction genuinely needs no protection. That is the common case and it buys a cheaper design, since the whole error budget goes on one side. Go two-sided when being unexpectedly better is itself a warning: a support bot that closes tickets far faster than a human may not be solving them. For a rate, use non-inferiority for two proportions. The framing is the one in one-tailed vs two-tailed tests, with the null shifted to the margin rather than sitting at zero.
Assumptions
The distributional assumptions are the t-test's. The ones that actually sink non-inferiority studies are about the design:
You have set the direction correctly. The explicit higher is better / lower is better switch exists because the two hypotheses are mirror images and the wrong one yields a confident, precisely inverted conclusion — a small p-value pointing the wrong way. Revenue and retention are higher-is-better; latency, churn and handling time are lower-is-better.
The margin was fixed before the data existed, and it is a commercial quantity: the loss you would knowingly accept in exchange for the saving, in the units of the metric. If nobody will commit to a number in advance, that is worth discovering before you run anything.
The comparison is a fair one. Non-inferiority is uniquely vulnerable to sloppiness: contamination, broken assignment or a noisy outcome all pull the observed difference towards zero and therefore towards your desired conclusion. In a superiority test sloppiness costs power; here it buys the answer you wanted.
How the calculation works
One hypothesis test, with the null shifted away from zero. Rather than asking whether the difference could be zero, we ask whether it could be as bad as −Δ, and reject in favour of "better than −Δ". The estimate, Welch's standard error and the degrees of freedom are identical to [the ordinary two-sample test](/calculators/two-sample-t-test); what changes is where the null sits and the fact that only one tail is in play. The expressions below assume higher is better, and flipping the switch mirrors every one of them.
Hypotheses (higher is better)
H₀: μ₁ − μ₂ ≤ −Δ vs H₁: μ₁ − μ₂ > −Δ
The null is that the new arm is worse by at least the margin, so the burden of proof sits on the change rather than on the incumbent.
Test statistic
t = (d − (−Δ)) / SE = (d + Δ) / SE
d is the observed difference, new minus incumbent, and above t₁₋α,df rejects. Note that d can be negative and the test still passes, provided the arm is not worse by Δ.
Standard error (Welch)
SE = √(s₁²/n₁ + s₂²/n₂)
Unpooled, with Welch–Satterthwaite degrees of freedom. Equal variances between an old system and a new one is an assumption with nothing behind it.
Confidence bound
d − t₁₋α,df · SE > −Δ
The one-sided 95% lower bound is the number to report, and it is also the lower limit of the two-sided 90% interval — which is why a non-inferiority readout and a TOST readout at the same α share an edge.
Sample size per arm
n = 2σ²(z₁₋α + z₁₋β)² / (Δ + d₀)²
d₀ is the signed difference you expect, negative if the new arm will probably be slightly worse. Assuming zero gives the cheapest design and the one most likely to disappoint: a shortfall of a third of the margin more than doubles it.
Lower is better
t = (Δ − d) / SE, bound: d + t₁₋α,df · SE < Δ
The mirror image, for latency, cost per acquisition and churn. Getting it backwards produces not a nonsense number but a plausible one that says the opposite of the truth.
Worked example
You want to replace a heavyweight recommendation model with one that costs a tenth as much to serve. Revenue per session is the guardrail, higher is better, and finance agreed in advance that a drop of up to 25 cents is worth the saving. The test ran three weeks at a 50/50 split, 60,000 sessions per arm.
Direction
Higher is better
Non-inferiority margin (Δ)
$0.25 per session
Incumbent model
n = 60,000, mean $8.40, SD $14.00
Cheap model
n = 60,000, mean $8.32, SD $13.80
Significance level (α)
0.05, one-sided
Standard error
Welch, unpooled
Observed difference −$0.08 per session, standard error $0.080. The statistic is (−0.08 + 0.25) / 0.080 = 2.12, a one-sided p of 0.017, and the 95% lower confidence bound is −$0.21. That bound clears the −$0.25 margin, so non-inferiority is established.
The headline is not that the cheap model performed the same — it lost eight cents a session, and that point estimate is the best guess at what shipping will cost. The claim is narrower: the data rules out a loss as large as 25 cents with 95% confidence, so the saving survives the worst case the evidence permits. The conventional comparison gives a two-sided p of 0.32, which would have been reported as "no difference" and justified nothing. Now flip the direction switch by mistake: the statistic becomes (0.25 + 0.08) / 0.080 = 4.11 and p collapses below 0.0001. Here that happens to land on the same decision, but with a 40-cent drop the correct test returns p = 0.97 — a clear failure — while the flipped one still returns p below 0.0001.
Interpreting the output
Report the confidence bound, not the p-value. "The 95% lower bound on revenue per session is −$0.21, against an agreed margin of −$0.25" is a sentence a finance director can act on. "p = 0.017" is not, and it invites the reading that the model was shown to be as good — a stronger claim than the data supports.
Keep the point estimate in view for that reason. Non-inferiority answers a question about the worst case and says nothing about the expected one, which here is a real if tolerable loss. Multiply it by annual sessions before you celebrate. Our note on why the uplift in A/B tests often differs from real-world results applies with equal force to declines.
A failed test is not proof of inferiority. If the bound lands at −$0.31 against a margin of −$0.25, you have not shown the new model is worse by more than the margin; you have failed to show it is not, which usually means the study was too small. The remedy is more data or a properly renegotiated margin — not a rerun with the direction switch flipped.
Finally, be careful about stacking claims. Each variant judged non-inferior to the last can drift a full margin from the original, and after four such decisions the live system may be materially worse than the one you started with while every test passed. Clinical statisticians call it biocreep; anchor to a preserved baseline. That discipline is what our causal inference work and most of our case studies are about.
Frequently asked questions
Should the one-sided alpha be 0.05 or 0.025?
Regulated clinical work conventionally uses one-sided 0.025, so the non-inferiority claim carries the same error rate as one side of a standard two-sided test. Product teams almost always use one-sided 0.05, which is defensible when the cost of a wrong call is a recoverable revenue dip rather than a patient outcome. The choice is worth about 25% more sample at 0.025, and the only wrong answer is deciding after the result comes in. Pick one, write it in the plan, and use the matching confidence bound in the readout.
What if nobody will commit to a margin?
Then you cannot run the test, and that is genuinely useful information rather than an obstacle. A refusal to name a tolerable loss usually means the trade-off has not been thought through, or that different stakeholders hold incompatible numbers in their heads. A productive way in is to work backwards from the saving: if the change frees 400,000 dollars a year, what annual revenue loss would still leave it worthwhile? Divide by expected sessions and you have a margin with a paper trail behind it.
My new variant looks better. Can I claim superiority instead?
Yes, and this is one of the few places where switching hypotheses after the fact is legitimate. Testing for superiority once non-inferiority is established does not inflate the overall error rate, because the hypotheses are ordered and the superiority test is only reached if the first one passes. The reverse move is not allowed: failing to demonstrate superiority and then declaring non-inferiority against a margin invented afterwards is exactly the manoeuvre the whole framework exists to prevent.
Why is a non-inferiority test cheaper than an equivalence test?
Because only one hypothesis has to be rejected rather than two. In an equivalence test the power requirement is split across both one-sided tests, which pushes the beta term up; here the whole error budget sits on the side you care about. At the same margin, alpha and power, a one-sided non-inferiority design typically needs somewhere around a quarter fewer observations per arm than the two-sided equivalence version. That is a real saving, but it is only available if you would honestly take no action on a surprise in the good direction.
Should I analyse everyone assigned, or only those who actually got the change?
This is the one place where the usual advice reverses. In a superiority test, analysing everyone as assigned is conservative, because non-compliance dilutes the difference towards zero. In a non-inferiority test, dilution towards zero pushes you towards the conclusion you want, so the as-assigned analysis is anti-conservative. The standard recommendation is to run both the as-assigned and the as-treated analysis and require them to agree before making the claim. If they disagree, you have a delivery problem to fix before you have a result to report.
Cost-saving changes need a guardrail with a number on it. We set the margin, size the study and write the decision rule before launch. Causal Inference Analysis
References
Wellek, S. (2010). Testing Statistical Hypotheses of Equivalence and Noninferiority (2nd ed.). Chapman & Hall/CRC.
Piaggio, G., Elbourne, D. R., Pocock, S. J., Evans, S. J. W., & Altman, D. G. (2012). Reporting of noninferiority and equivalence randomized trials: extension of the CONSORT 2010 statement. JAMA, 308(24), 2594-2604.
Chow, S.-C., Shao, J., Wang, H., & Lokhnygina, Y. (2018). Sample Size Calculations in Clinical Research (3rd ed.). Chapman & Hall/CRC.