bentools/split-test-analyzer

用于拆分测试/AB测试的贝叶斯概率计算器。

1.1 2017-12-01 10:26 UTC

This package is auto-updated.

Last update: 2024-09-15 00:03:40 UTC


README

Latest Stable Version License Build Status Coverage Status Quality Score Total Downloads

Split Test Analyzer

此PHP工具可以帮助您计算不同版本的拆分测试,其成为最佳测试的概率。

它是用于AB拆分测试图形贝叶斯计算器的JS工具的PHP版本。

概念

一个Variation对象由3个信息组成

  • 一个key来标识它(例如,着陆页/横幅ID)
  • 动作总数(比如,唯一访客数)
  • 成功动作的数量(比如,转化数)

现在您可以将这些3个对象进行比较,并计算它们成为最佳的概率。

用法

use BenTools\SplitTestAnalyzer\SplitTestAnalyzer;
use BenTools\SplitTestAnalyzer\Variation;

require_once __DIR__ . '/vendor/autoload.php';

$variations = [
    new Variation('LP #1', 8686347, 932),
    new Variation('LP #2', 7305026, 804),
    new Variation('LP #3', 4592639, 371),
    new Variation('LP #4', 4590186, 402),
    new Variation('LP #5', 4532325, 470),
    new Variation('LP #6', 4531653, 494),
];

$predictor = SplitTestAnalyzer::create()->withVariations(...$variations);
foreach ($predictor->getResult() as $key => $value) {
    printf('%s has %d%% chances to be the best one.' . PHP_EOL, $key, $value);
}

print PHP_EOL;

printf('The best one is: %s', $predictor->getBestVariation());

输出

LP #1 has 15% chances to be the best one.
LP #2 has 43% chances to be the best one.
LP #3 has 0% chances to be the best one.
LP #4 has 0% chances to be the best one.
LP #5 has 7% chances to be the best one.
LP #6 has 34% chances to be the best one.

The best one is: LP #2

由于贝叶斯计算器中使用的随机性,结果可能会有所不同。

为了提高性能,您可以通过SplitTestAnalyzer::create(100)减少样本数量,但这样您需要在性能和可靠性之间做出选择。

安装

此库需要PHP 7.0及以上版本。

composer require bentools/split-test-analyzer

测试

./vendor/bin/phpunit

另请参阅

bentools/cartesian-product

bentools/pager