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

What's inside

Module Purpose
sample_size Required per-arm sample size for a given MDE, and the inverse
cuped Deng et al. (2013) CUPED variance reduction
ratio Delta-method variance for ratio metrics (revenue/session, etc.)
sequential mSPRT always-valid p-values for peeking-robust experiments

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.1.0.tar.gz (8.9 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.1.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: experiment_toolkit-0.1.0.tar.gz
  • Upload date:
  • Size: 8.9 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.1.0.tar.gz
Algorithm Hash digest
SHA256 f18ee007c91bc2403ad59f99f902d96bc747b4298036aaa24230e136796e6b09
MD5 2bf9f230672f8134c070379f23e5d440
BLAKE2b-256 6712c5e414371b0f8cb59bf7b5fa179e321e6d09b03662466ffa5d1a98d930af

See more details on using hashes here.

Provenance

The following attestation bundles were made for experiment_toolkit-0.1.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.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for experiment_toolkit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 18bc100dbde114337e0a03ccb96c4a758e0aa90403e289af66f4ae353176d7bf
MD5 e534ffbee2aef850f501f3b2d6bc2f0b
BLAKE2b-256 5bcb3e4ef0ae9057babb7bcdac9c4ba4faaf09d82a3af588a978b6ebbd9b3530

See more details on using hashes here.

Provenance

The following attestation bundles were made for experiment_toolkit-0.1.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