experiments-stats
A dependency-free TypeScript port of GrowthBook's gbstats for assignment, sequential and Bayesian tests, CUPED, SRM and power.
@delmaredigital/experiments-stats is the statistics engine behind payload-experiments, published as its own package. It is a pure TypeScript port of GrowthBook's MIT-licensed statistics and assignment code. Use it directly if you want gbstats-equivalent results in a Node.js or browser codebase without running Python.
Most people want payload-experiments instead; it installs this package as a dependency.
npm i @delmaredigital/experiments-statsThe current version is 0.1.0, pre-1.0. It requires Node.js >=22.23.4 when run on Node, is ESM-only, and has no runtime dependencies and no side effects.
What it covers
- Assignment: GrowthBook's SDK hash and bucket ranges, plus helpers for whole-number weights, layers and holdout rollouts. See Assignment.
- Inference: proportion, sample-mean and CUPED statistics, relative and absolute effect moments, sequential two-sided and one-sided tests, and the Bayesian effect test. See Inference.
- Diagnostics and power: sample-ratio mismatch, mid-experiment power, and pre-experiment power and minimum detectable effect. See Diagnostics and power.
- Capping and aggregation: percentile caps, per-unit summaries and statistic builders. See Capping and aggregation.
Every function is synchronous and deterministic and takes plain numbers, arrays and objects. The package does not collect exposures or events.
Example
import {
summarizeUnits,
buildStatistic,
sequentialTwoSidedTTest,
checkSrm,
} from '@delmaredigital/experiments-stats'
// Per-person 0/1 outcomes for each group
const control = buildStatistic('binomial', summarizeUnits(controlValues))
const variant = buildStatistic('binomial', summarizeUnits(variantValues))
const result = sequentialTwoSidedTTest(control, variant, { alpha: 0.05 })
if (result.errorMessage === null) {
console.log(result.expected, result.ci) // relative lift and its sequential interval
}
const srmP = checkSrm([controlValues.length, variantValues.length], [50, 50])
if (srmP < 0.001) console.warn('Sample-ratio mismatch')Accuracy
The port is pinned to GrowthBook commit 0553a68def700abbcaaca8f5096da913f197804c and tested against fixtures generated by running gbstats itself, using |a − b| ≤ 1e-9 · max(1, |b|) (absolute tolerance below |b| = 1, relative tolerance above it). See Accuracy and fixtures.
License
MIT. Statistical methods are ported from GrowthBook gbstats (MIT, © GrowthBook, Inc.); the package's NOTICE lists the source pin and every ported path. No GrowthBook enterprise code is used.

