@shotlingo/ab-test-sample-size
v0.1.0
Published
A/B test sample-size, total-size, and test-duration calculator for App Store Product Page Optimization and Google Play Store Listing Experiments — two-proportion z-test, zero dependencies.
Maintainers
Readme
@shotlingo/ab-test-sample-size
A/B test sample-size, total-size, and test-duration calculator for App Store Product Page Optimization and Google Play Store Listing Experiments. Two-proportion z-test (95% two-sided significance, 80% power). Zero dependencies, no network calls.
Full interactive reference (calculator + worked examples): shotlingo.com/tools/ab-test-sample-size-calculator
Install
npm install @shotlingo/ab-test-sample-sizeUsage
import {
sampleSizePerVariant,
totalSampleSize,
estimateTestDurationDays,
} from '@shotlingo/ab-test-sample-size';
// 25% baseline conversion rate, detect a 10% relative lift
sampleSizePerVariant(25, 10);
// => 4501
totalSampleSize(25, 10);
// => 9002
// With 200 visitors/day per variant, how many days to collect that sample?
estimateTestDurationDays(200, 25, 10);
// => 23API
sampleSizePerVariant(baselineRatePct: number, mdeRelativePct: number): number— required sample size per variant. ReturnsInfinityfor degenerate inputs (non-improving or out-of-range rates) instead ofNaN.totalSampleSize(baselineRatePct: number, mdeRelativePct: number): number— sample size across both variants.estimateTestDurationDays(dailyVisitorsPerVariant: number, baselineRatePct: number, mdeRelativePct: number): number— days to collect the required sample, floored at 7 (daily conversion swings by weekday, so shorter tests skew toward whichever days they happened to cover).Z_ALPHA_2_SIDED_95,Z_BETA_POWER_80— the fixed z-values behind the defaults.
License
MIT
