Bayesian A/B testing for proportions
Project description
Bayesian A/B Testing for Proportions
A Python package for Bayesian hypothesis testing of binary (pass/fail) outcomes in A/B experiments. It provides three complementary models, Savage–Dickey Bayes factors, posterior predictive checks, Bayes Factor Design Analysis (BFDA) for sample-size planning, and publication-ready plots. Please check out our Getting Started guide for installation and quick examples.
Models
| Model | Class | Method | When to use |
|---|---|---|---|
| Non-paired Beta–Bernoulli | NonPairedBayesPropTest |
Conjugate Beta posterior | Independent groups, exact & fast |
| Paired Logistic (Laplace) | PairedBayesPropTest |
MAP + Laplace approximation | Paired scores, large n, fast iteration |
| Paired Logistic (Pólya–Gamma) | PairedBayesPropTestPG |
Exact Gibbs sampling | Paired scores, small n, exact posterior |
Quick start
from bayesprop.resources.bayes_paired_pg import PairedBayesPropTestPG
from bayesprop.utils.utils import simulate_paired_scores
# Simulate paired binary data
sim = simulate_paired_scores(N=200, delta_A=0.5, seed=42)
y_A, y_B = sim.y_A, sim.y_B
# Fit & summarise
model = PairedBayesPropTestPG(seed=42, n_iter=2000, burn_in=500, n_chains=4).fit(y_A, y_B)
print(model.summary) # PairedSummary with mean_delta, ci_95, P(A>B), …
# Hypothesis test
bf = model.savage_dickey_test() # SavageDickeyResult with BF_10, decision, …
# Plots
model.plot_posteriors()
model.plot_ppc(seed=42)
model.plot_savage_dickey()
Package structure
├── pyproject.toml
├── justfile # task runner (just <recipe>)
├── .pre-commit-config.yaml # ruff format + lint hooks
├── data/ # evaluation datasets
├── docs/ # model derivations & MkDocs site
├── src
│ ├── bayesprop
│ │ ├── config/ # global_config, YAML configs
│ │ ├── resources/
│ │ │ ├── bayes_nonpaired.py # NonPairedBayesPropTest
│ │ │ ├── bayes_paired_laplace.py # PairedBayesPropTest
│ │ │ ├── bayes_paired_pg.py # PairedBayesPropTestPG
│ │ │ ├── bfda_utils.py # BFDA helpers
│ │ │ └── data_schemas.py # Pydantic models
│ │ ├── services/
│ │ │ └── file.py # CSV / JSON / YAML / XLSX I/O
│ │ └── utils/
│ │ └── utils.py # simulate, BFDA power curves, plots
│ └── notebooks/
│ ├── bayesian_AB_model_comparison_nonpaired.ipynb
│ ├── bayesian_AB_model_comparison_paired_laplace.ipynb
│ └── bayesian_AB_model_comparison_paired_gibbs.ipynb
└── tests/
├── test_bayes_nonpaired.py
├── test_bayes_paired_laplace.py
├── test_bayes_paired_pg.py
├── test_bfda_utils.py
├── test_data_schemas.py
└── test_file_services.py
Installation
pip install bayesprop
Or with uv:
uv pip install bayesprop
For development (from source):
git clone https://github.com/AVoss84/bayesProp.git
cd bayesprop
uv venv --python 3.13
uv sync
source .venv/bin/activate
Dependencies
- Python ≥ 3.13
- numpy, scipy, matplotlib, pandas
- pydantic (v2)
- polyagamma
References
- Gelman, A., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, A. & Rubin, D. B. (2013). Bayesian Data Analysis (3rd ed.). Chapman & Hall/CRC.
- Kruschke, J. K. (2018). Rejecting or accepting parameter values in Bayesian estimation. Advances in Methods and Practices in Psychological Science, 1(2), 270–280.
- Polson, N. G., Scott, J. G. & Windle, J. (2013). Bayesian inference for logistic models using Pólya–Gamma latent variables. JASA, 108(504), 1339–1349.
- Schönbrodt, F. D. & Wagenmakers, E.-J. (2018). Bayes factor design analysis: Planning for compelling evidence. Psychonomic Bulletin & Review, 25(1), 128–142.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bayesprop-0.1.0.1.tar.gz.
File metadata
- Download URL: bayesprop-0.1.0.1.tar.gz
- Upload date:
- Size: 51.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f1466cb715d605c08b02aa232f52cedfb541eefbae6a8e4516916cb3afb8b49
|
|
| MD5 |
976aefedbbd181bd3c17256b5e2b6b51
|
|
| BLAKE2b-256 |
6256aef5644ab198f45d200e45e698b2785ad68833ef2e8ae5441695798f03dd
|
Provenance
The following attestation bundles were made for bayesprop-0.1.0.1.tar.gz:
Publisher:
publish_pypi.yml on AVoss84/bayesProp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bayesprop-0.1.0.1.tar.gz -
Subject digest:
2f1466cb715d605c08b02aa232f52cedfb541eefbae6a8e4516916cb3afb8b49 - Sigstore transparency entry: 1442426834
- Sigstore integration time:
-
Permalink:
AVoss84/bayesProp@efaaf2fc8b5bd6f7d1fdeed8677d6857107399b1 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/AVoss84
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yml@efaaf2fc8b5bd6f7d1fdeed8677d6857107399b1 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file bayesprop-0.1.0.1-py3-none-any.whl.
File metadata
- Download URL: bayesprop-0.1.0.1-py3-none-any.whl
- Upload date:
- Size: 43.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b55f83f2b6796603ebddb395c6a84bd312b01dad2c45fbe4e828e1f8e0b6aea4
|
|
| MD5 |
9d0175a01168bfe1d2c4f70346afd67c
|
|
| BLAKE2b-256 |
715647e9320f8d013f96378a405be65b2ee5f5b413a25566dd47dae0c9181cc5
|
Provenance
The following attestation bundles were made for bayesprop-0.1.0.1-py3-none-any.whl:
Publisher:
publish_pypi.yml on AVoss84/bayesProp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bayesprop-0.1.0.1-py3-none-any.whl -
Subject digest:
b55f83f2b6796603ebddb395c6a84bd312b01dad2c45fbe4e828e1f8e0b6aea4 - Sigstore transparency entry: 1442426975
- Sigstore integration time:
-
Permalink:
AVoss84/bayesProp@efaaf2fc8b5bd6f7d1fdeed8677d6857107399b1 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/AVoss84
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yml@efaaf2fc8b5bd6f7d1fdeed8677d6857107399b1 -
Trigger Event:
workflow_dispatch
-
Statement type: