Skip to main content

experiment-toolkit

Small, well-tested utilities for online controlled experiments.

CI PyPI Python License: MIT

hero

What's inside

Module Purpose
sample_size Per-arm sample size / MDE, CUPED-aware (rho kwarg)
cuped Deng et al. (2013) CUPED variance reduction
ratio Delta-method variance for ratio metrics (revenue/session, etc.)
sequential mSPRT always-valid p-values, with optional CUPED compounding
cs_did Callaway & Sant'Anna (2021) staggered DiD, robust to heterogeneous effects
sensitivity E-value and Rosenbaum bounds for observational-causal sensitivity

Every function is tested, typed, and has a reference to the paper it implements.

Install

pip install experiment-toolkit

Or from source:

pip install git+https://github.com/wavde/experiment-toolkit.git

Quick start

from experiment_toolkit import sample_size_for_mde, apply_cuped, msprt_pvalue

# How many users do I need per arm to detect a 2% lift (sd=1.0)?
n = sample_size_for_mde(mde=0.02, std_dev=1.0, alpha=0.05, power=0.80)
# ~39,000 per arm

# Apply CUPED with a pre-experiment covariate
y_adj = apply_cuped(y, pre_period_y)

# Always-valid p-value — safe to peek
p = msprt_pvalue(delta_hat=0.015, sigma=1.0, n_per_arm=5000, tau=0.05)

CLI

The CLI wraps sample-size and mde. The other modules (cuped, ratio, sequential) are library-only.

experiment-toolkit sample-size --mde 0.02 --sd 1.0
# Required per-arm sample size: 39,244

experiment-toolkit mde --n 10000 --sd 1.0
# Detectable effect (MDE): 0.0396

Development

pip install -e ".[dev]"
pytest
ruff check .

References

  • Deng, Xu, Kohavi, Walker (2013) — CUPED
  • Deng, Knoblich, Lu (2018) — Delta Method in Metric Analytics
  • Johari, Pekelis, Walsh (2015) — Always Valid Inference
  • Kohavi, Tang, Xu (2020) — Trustworthy Online Controlled Experiments

License

MIT — see LICENSE.

Metadata

Release files for experiment-toolkit 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for experiment-toolkit 0.2.0
File Size Uploaded
experiment_toolkit-0.2.0.tar.gz 105.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for experiment-toolkit 0.2.0
File Interpreter ABI Platform
experiment_toolkit-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 122.5 kB

Release files / experiment_toolkit-0.2.0.tar.gz

Download URL experiment_toolkit-0.2.0.tar.gz
Size 105.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2ca38e18acf2fc6ba3f23dbc5bf805981072a3755e0cb724fc9702638231208e
BLAKE2b-256 checksum
How to use checksums
5af0b99a9391abb2a999189d02cbc018bb8e40edd37e7ad183a989529c1b652f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 20, 2026.

Transparency log

Release files / experiment_toolkit-0.2.0-py3-none-any.whl

Download URL experiment_toolkit-0.2.0-py3-none-any.whl
Size 17.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b91ec06d52cb802d9a31d91bb6a1973c01e088da3da5e2438ed19055785e3970
BLAKE2b-256 checksum
How to use checksums
461398105fe8bf1f146ac90cb8cabdea53d9ff10c48dca5cd562f35bff2b85c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 20, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page