コード例 #1
0
ファイル: UCB1Allocator.php プロジェクト: lwc/kumite
 public function allocate(\Kumite\Test $test, array $options)
 {
     $event = $options['event'];
     $ucbValues = array();
     foreach ($test->variantKeys() as $v) {
         $armCount = $this->getArmCount($v, $test);
         // try all variants at least once
         if ($armCount == 0) {
             return $v;
         }
         $r = $this->getConversionRate($v, $test, $event);
         $b = $this->getBonus($v, $test);
         $ucbValues[$v] = $r + $b;
     }
     // return variant with the highest chance for success
     return array_search(max($ucbValues), $ucbValues);
 }
コード例 #2
0
ファイル: RandomAllocator.php プロジェクト: lwc/kumite
 public function allocate(Test $test, array $options)
 {
     $keys = $test->variantKeys();
     $index = array_rand($keys);
     return $keys[$index];
 }