public function getLogNormalization()
 {
     $vars = $this->getVariables();
     $marginal = $vars[0]->getValue();
     $messages = $this->getMessages();
     $message = $messages[0]->getValue();
     $messageFromVariable = GaussianDistribution::divide($marginal, $message);
     return -GaussianDistribution::logProductNormalization($messageFromVariable, $message) + log(GaussianDistribution::cumulativeTo(($messageFromVariable->getMean() - $this->_epsilon) / $messageFromVariable->getStandardDeviation()));
 }
 public static function wWithinMargin($teamPerformanceDifference, $drawMargin)
 {
     $teamPerformanceDifferenceAbsoluteValue = abs($teamPerformanceDifference);
     $denominator = GaussianDistribution::cumulativeTo($drawMargin - $teamPerformanceDifferenceAbsoluteValue) - GaussianDistribution::cumulativeTo(-$drawMargin - $teamPerformanceDifferenceAbsoluteValue);
     if ($denominator < 2.222758749E-162) {
         return 1.0;
     }
     $vt = self::vWithinMargin($teamPerformanceDifferenceAbsoluteValue, $drawMargin);
     return $vt * $vt + (($drawMargin - $teamPerformanceDifferenceAbsoluteValue) * GaussianDistribution::at($drawMargin - $teamPerformanceDifferenceAbsoluteValue) - (-$drawMargin - $teamPerformanceDifferenceAbsoluteValue) * GaussianDistribution::at(-$drawMargin - $teamPerformanceDifferenceAbsoluteValue)) / $denominator;
 }
示例#3
0
 public function getLogNormalization()
 {
     $variables =& $this->getVariables();
     $marginal =& $variables[0]->getValue();
     $messages =& $this->getMessages();
     $message =& $messages[0]->getValue();
     $messageFromVariable = GaussianDistribution::divide($marginal, $message);
     $mean = $messageFromVariable->getMean();
     $std = $messageFromVariable->getStandardDeviation();
     $z = GaussianDistribution::cumulativeTo(($this->_epsilon - $mean) / $std) - GaussianDistribution::cumulativeTo((-$this->_epsilon - $mean) / $std);
     return -GaussianDistribution::logProductNormalization($messageFromVariable, $message) + log($z);
 }
 public function testCumulativeTo()
 {
     // Verified with WolframAlpha
     // (e.g. http://www.wolframalpha.com/input/?i=CDF%5BNormalDistribution%5B0%2C1%5D%2C+0.5%5D )
     $this->assertEquals(0.691462, GaussianDistribution::cumulativeTo(0.5), '', GaussianDistributionTest::ERROR_TOLERANCE);
 }
 public function getPlayerWinProbability(GameInfo $gameInfo, $playerRating, $opponentRating)
 {
     $ratingDifference = $playerRating - $opponentRating;
     // See equation 1.1 in the TrueSkill paper
     return GaussianDistribution::cumulativeTo($ratingDifference / (sqrt(2) * $gameInfo->getBeta()));
 }