Bandit
An A/B/x testing algorithm written in PHP by implementing the solution to the multi armed bandit problem
Install / Use
/learn @offdev/BanditREADME
Offdev/Bandit
An A/B/x testing algorithm written in PHP by implementing the solution to the multi armed bandit problem
Requirements
- PHP >= 7.4
- Composer
Installation
$ composer require offdev/bandit
General Usage
First, you need to set up a machine, and its possible levers. A lever might have already been pulled a few times, and some levers may also have rewarded the lucky person which pulled it, so adjust those numbers accordingly. Example:
use Offdev\Bandit\Lever;
use Offdev\Bandit\Machine;
$machine = new Machine(
new Lever('first-lever', 123, 1),
new Lever('second-lever', 108, 3),
new Lever('third-lever', 115, 0),
);
Now you need a strategy to solve your problem. See this link for more information about strategies, and have a look at the example ones I have included in src/php/Strategies. Example:
use Offdev\Bandit\Strategies\EpsilonGreedy;
$strategy = new EpsilonGreedy();
$winningLever = $strategy->solve($machine);
It is as simple as that :)
TODO
Add more docs :)
Related Skills
node-connect
351.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
