Skip to main content

Small, well-tested utilities for online controlled experiments: sample size, CUPED, sequential testing, delta-method variance.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

experiment_toolkit-0.2.0.tar.gz (105.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

experiment_toolkit-0.2.0-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file experiment_toolkit-0.2.0.tar.gz.

File metadata

  • Download URL: experiment_toolkit-0.2.0.tar.gz
  • Upload date:
  • Size: 105.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for experiment_toolkit-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2ca38e18acf2fc6ba3f23dbc5bf805981072a3755e0cb724fc9702638231208e
MD5 d1227f59d7cc0dee73d2af86b5a093f5
BLAKE2b-256 5af0b99a9391abb2a999189d02cbc018bb8e40edd37e7ad183a989529c1b652f

See more details on using hashes here.

Provenance

The following attestation bundles were made for experiment_toolkit-0.2.0.tar.gz:

Publisher: publish.yml on wavde/experiment-toolkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file experiment_toolkit-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for experiment_toolkit-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b91ec06d52cb802d9a31d91bb6a1973c01e088da3da5e2438ed19055785e3970
MD5 f307fda6bb32ea37bfd99ee9cf1ffacd
BLAKE2b-256 461398105fe8bf1f146ac90cb8cabdea53d9ff10c48dca5cd562f35bff2b85c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for experiment_toolkit-0.2.0-py3-none-any.whl:

Publisher: publish.yml on wavde/experiment-toolkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page