An A/B/x testing algorithm written in PHP by implementing the solution to the multi armed bandit problem
- PHP >= 7.4
- Composer
$ composer require offdev/banditFirst, 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:
useOffdev\Bandit\Lever;
useOffdev\Bandit\Machine;
$machine = newMachine(
newLever('first-lever', 123, 1),
newLever('second-lever', 108, 3),
newLever('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:
useOffdev\Bandit\Strategies\EpsilonGreedy;
$strategy = newEpsilonGreedy();
$winningLever = $strategy->solve($machine);It is as simple as that :)
Add more docs :)