Bayesian multi-armed bandit implementation with adaptive Thompson Sampling
Project description
BayesMAB
Bayesian Multi-Armed Bandit with adaptive Thompson Sampling, suitable for A/B testing and real-time decision-making.
Install
pip install bayesmab
Usage Example
An example script is included in the examples/ directory.
You can run it with:
python examples/run_bernoulli_bandit.py
The example initializes a bandit with three arms, each simulating a different true conversion rate. It uses:
-
Thompson Sampling to allocate "traffic" to each arm based on uncertainty
-
Updates posterior beliefs as binary rewards are observed
-
Tracks and visualizes:
-
Posterior distributions
-
Posterior mean estimates over time
-
Cumulative regret
-
Traffic allocation per arm
-
This simulates an A/B/n test where better-performing variants gradually receive more attention, showing how Bayesian bandits adaptively optimize decisions under uncertainty.
Project details
Release history Release notifications | RSS feed
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 bayesmab-1.0.0.tar.gz.
File metadata
- Download URL: bayesmab-1.0.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80ac158bb9f7a99e3bb1f6e881047e861ce23c33a80922ca6f685f32b175bb89
|
|
| MD5 |
71837b5d7825aebe6b0e9df7ed706777
|
|
| BLAKE2b-256 |
8be545152241d386a8913b960394305650afba69c12d401da99426d4a27650b9
|
File details
Details for the file bayesmab-1.0.0-py3-none-any.whl.
File metadata
- Download URL: bayesmab-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e0898f8f3510d2128fd0f3362032b4679c956461303d5561798d9d85a265c18
|
|
| MD5 |
d980dc3dddf8362ed8fc07de8ccf5100
|
|
| BLAKE2b-256 |
b6dcadf3fed599fac20b7df5d8bafa6ca87c2fc7177615ad6590c9ac09597a73
|