abby
1.1.1
abby是一個簡單但功能強大的 PHP A/B 測試庫。
該庫可讓您輕鬆設定測試(實驗)、其控制組和變體組、追蹤使用者、獲取詳細的統計資料(例如建議的樣本大小,並確定結果的置信度),包括實驗是否達到統計顯著性。
獲勝者(和置信度)是使用貝葉斯統計確定的,計算結果的 p 值以檢查是否可以拒絕原假設。也使用雙尾檢定來計算隨附的最小樣本量,以控制錯誤發現率。
abby是無依賴性的,並且完全與資料庫無關,這意味著它只需處理您提供的數據,並公開多種方法供您將結果儲存在您自己選擇的儲存中。
composer require andreekeberg/ abby
// Setup a new Token instance
$ token = new abby Token ();
// If we can't find an existing token cookie, generate one and set tracking cookie
if (! $ token -> getValue ()) {
$ token -> generate ()-> setCookie ();
}
// Setup a User instance
$ user = new abby User ();
// Associate the token with our user
$ user -> setToken ( $ token );
// List of experiments associated with a tracking token
$ data = [
[
' id ' => 1 ,
' group ' => 1 ,
' viewed ' => true ,
' converted ' => false
]
];
// Loop through users existing experiments and add them to our user instance
foreach ( $ data as $ item ) {
// Setup experiment instance based on an existing experiment
$ experiment = new abby Experiment ([
' id ' => $ item [ ' id ' ]
]);
// Setup a group instance based on stored data
$ group = new abby Group ([
' type ' => $ item [ ' group ' ]
]);
// Add the experiment (including their group, and whether they have viewed and converted)
$ user -> addExperiment ( $ experiment , $ group , $ item [ ' viewed ' ], $ item [ ' converted ' ]);
}
// Experiment data
$ data = [
' id ' => 2
];
// Make sure the experiment isn't already in the users list
if (! $ user -> hasExperiment ( $ data [ ' id ' ])) {
// Setup a new experiment instance
$ experiment = new abby Experiment ([
' id ' => $ data [ ' id ' ]
]);
// Assign the user to either control or variation in the experiment
$ group = $ user -> assignGroup ( $ experiment );
// Add the experiment (including assigned group) to our user instance
$ user -> addExperiment ( $ experiment , $ group );
}
// Getting updated user experiment list
$ user -> getExperiments ();
// Store updated experiment list for our user
// Experiment data
$ data = [
' id ' => 1
];
// Record a view for the experiment in question
$ user -> setViewed ( $ data [ ' id ' ]);
// If the user is part of the variation group
if ( $ user -> inVariation ( $ data [ ' id ' ])) {
// Apply a custom class to an element, load a script, etc.
}
// Experiment data
$ data = [
' id ' => 1
];
// On a custom goal, check if user has viewed the experiment and define a conversion
if ( $ user -> hasViewed ( $ data [ ' id ' ])) {
$ user -> setConverted ( $ data [ ' id ' ]);
}
// Getting updated user experiment data
$ user -> getExperiments ();
// Store updated data for our user
// Setup experiment instance with stored results
$ experiment = new abby Experiment ([
' groups ' => [
[
' name ' => ' Control ' ,
' views ' => 3000 ,
' conversions ' => 300
],
[
' name ' => ' Variation ' ,
' views ' => 3000 ,
' conversions ' => 364
]
]
]);
// Retrieve the results
$ result = $ experiment -> getResult ();
// Get the winner
$ winner = $ result -> getWinner ();
/**
* Get whether we can be confident of the result (even if we haven't
* reached the minimum number of views for each variant)
*/
$ confident = $ result -> isConfident ();
/**
* Get the minimum sample size (number of views) required for each group to
* reach statistical significance, given the control groups current conversion
* rate (based on the configured minimumDetectableEffect)
*/
$ minimum = $ result -> getMinimumSampleSize ();
/**
* Get whether the results are statistically significant
*/
$ significant = $ result -> isSignificant ();
/**
* Get complete experiment result
*/
$ summary = $ result -> getAll ();
閱讀貢獻指南。
請參閱變更日誌以了解該項目的完整歷史記錄。
abby根據 MIT 許可證獲得許可。