mirror of
https://github.com/furyfire/trueskill.git
synced 2025-01-15 17:37:39 +00:00
More docs
This commit is contained in:
@ -36,8 +36,6 @@ abstract class FactorGraphLayer
|
||||
return $this->inputVariablesGroups;
|
||||
}
|
||||
|
||||
// HACK
|
||||
|
||||
public function getParentFactorGraph(): TrueSkillFactorGraph
|
||||
{
|
||||
return $this->parentFactorGraph;
|
||||
|
@ -9,11 +9,17 @@ namespace DNW\Skills;
|
||||
*/
|
||||
class GameInfo
|
||||
{
|
||||
private const DEFAULT_BETA = 4.1666666666666666666666666666667; // Default initial mean / 6
|
||||
/**
|
||||
* Default initial mean / 6
|
||||
*/
|
||||
private const DEFAULT_BETA = 4.1666666666666666666666666666667;
|
||||
|
||||
private const DEFAULT_DRAW_PROBABILITY = 0.10;
|
||||
|
||||
private const DEFAULT_DYNAMICS_FACTOR = 0.083333333333333333333333333333333; // Default initial mean / 300
|
||||
/**
|
||||
* Default initial mean / 300
|
||||
*/
|
||||
private const DEFAULT_DYNAMICS_FACTOR = 0.083333333333333333333333333333333;
|
||||
|
||||
private const DEFAULT_INITIAL_MEAN = 25.0;
|
||||
|
||||
|
@ -12,12 +12,20 @@ namespace DNW\Skills\Numerics;
|
||||
*/
|
||||
class GaussianDistribution implements \Stringable
|
||||
{
|
||||
//sqrt(2*pi)
|
||||
//from https://www.wolframalpha.com/input?i=sqrt%282*pi%29
|
||||
/**
|
||||
* Square Root 2π.
|
||||
* Precalculated constant for performance reasons
|
||||
* sqrt(2*pi)
|
||||
* from https://www.wolframalpha.com/input?i=sqrt%282*pi%29
|
||||
*/
|
||||
private const M_SQRT_2_PI = 2.5066282746310005024157652848110452530069867406099383166299235763;
|
||||
|
||||
//log(sqrt(2*pi))
|
||||
//From https://www.wolframalpha.com/input?i=log%28sqrt%282*pi%29%29
|
||||
/**
|
||||
* Log of Square Root 2π.
|
||||
* Precalculated constant for performance reasons
|
||||
* 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
|
||||
@ -67,9 +75,11 @@ class GaussianDistribution implements \Stringable
|
||||
return $this->precisionMean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Great derivation of this is at 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);
|
||||
}
|
||||
|
||||
@ -92,14 +102,18 @@ 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(
|
||||
@ -108,7 +122,9 @@ 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,7 +30,6 @@ 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;
|
||||
|
Reference in New Issue
Block a user