Compare commits

..

No commits in common. "49953d13290dd1467ab8258ec59367bd14e8a75f" and "783a12e7448a89abf2188bf1f87801073c15e222" have entirely different histories.

4 changed files with 14 additions and 34 deletions

@ -36,6 +36,8 @@ abstract class FactorGraphLayer
return $this->inputVariablesGroups;
}
// HACK
public function getParentFactorGraph(): TrueSkillFactorGraph
{
return $this->parentFactorGraph;

@ -9,17 +9,11 @@ namespace DNW\Skills;
*/
class GameInfo
{
/**
* Default initial mean / 6
*/
private const DEFAULT_BETA = 4.1666666666666666666666666666667;
private const DEFAULT_BETA = 4.1666666666666666666666666666667; // Default initial mean / 6
private const DEFAULT_DRAW_PROBABILITY = 0.10;
/**
* Default initial mean / 300
*/
private const DEFAULT_DYNAMICS_FACTOR = 0.083333333333333333333333333333333;
private const DEFAULT_DYNAMICS_FACTOR = 0.083333333333333333333333333333333; // Default initial mean / 300
private const DEFAULT_INITIAL_MEAN = 25.0;

@ -12,20 +12,12 @@ namespace DNW\Skills\Numerics;
*/
class GaussianDistribution implements \Stringable
{
/**
* Square Root 2π.
* Precalculated constant for performance reasons
* sqrt(2*pi)
* @link https://www.wolframalpha.com/input?i=sqrt%282*pi%29 Source of value
*/
//sqrt(2*pi)
//from https://www.wolframalpha.com/input?i=sqrt%282*pi%29
private const M_SQRT_2_PI = 2.5066282746310005024157652848110452530069867406099383166299235763;
/**
* Log of Square Root 2π.
* Precalculated constant for performance reasons
* log(sqrt(2*pi))
* @link https://www.wolframalpha.com/input?i=log%28sqrt%282*pi%29%29 Source of value
*/
//log(sqrt(2*pi))
//From https://www.wolframalpha.com/input?i=log%28sqrt%282*pi%29%29
private const M_LOG_SQRT_2_PI = 0.9189385332046727417803297364056176398613974736377834128171515404;
// precision and precisionMean are used because they make multiplying and dividing simpler
@ -75,12 +67,9 @@ class GaussianDistribution implements \Stringable
return $this->precisionMean;
}
/**
* Great derivation of this is at
* @link http://www.astro.psu.edu/~mce/A451_2/A451/downloads/notes0.pdf
*/
public function getNormalizationConstant(): float
{
// Great derivation of this is at http://www.astro.psu.edu/~mce/A451_2/A451/downloads/notes0.pdf
return 1.0 / (self::M_SQRT_2_PI * $this->standardDeviation);
}
@ -103,18 +92,14 @@ class GaussianDistribution implements \Stringable
return $result;
}
/**
* For details, see http://www.tina-vision.net/tina-knoppix/tina-memo/2003-003.pdf
* for multiplication, the precision mean ones are easier to write :)
*/
// For details, see http://www.tina-vision.net/tina-knoppix/tina-memo/2003-003.pdf
// for multiplication, the precision mean ones are easier to write :)
public static function multiply(GaussianDistribution $left, GaussianDistribution $right): self
{
return GaussianDistribution::fromPrecisionMean($left->precisionMean + $right->precisionMean, $left->precision + $right->precision);
}
/**
* Computes the absolute difference between two Gaussians
*/
// Computes the absolute difference between two Gaussians
public static function absoluteDifference(GaussianDistribution $left, GaussianDistribution $right): float
{
return max(
@ -123,9 +108,7 @@ class GaussianDistribution implements \Stringable
);
}
/**
* Computes the absolute difference between two Gaussians
*/
// Computes the absolute difference between two Gaussians
public static function subtract(GaussianDistribution $left, GaussianDistribution $right): float
{
return GaussianDistribution::absoluteDifference($left, $right);

@ -30,6 +30,7 @@ class Player implements ISupportPartialPlay, ISupportPartialUpdate, \Stringable
float $partialUpdatePercentage = self::DEFAULT_PARTIAL_UPDATE_PERCENTAGE
)
{
// If they don't want to give a player an id, that's ok...
Guard::argumentInRangeInclusive($partialPlayPercentage, 0.0, 1.0, 'partialPlayPercentage');
Guard::argumentInRangeInclusive($partialUpdatePercentage, 0, 1.0, 'partialUpdatePercentage');
$this->PartialPlayPercentage = $partialPlayPercentage;