From 3a14da538882a12350aed2e190d8b80278213932 Mon Sep 17 00:00:00 2001 From: Jens True Date: Mon, 26 Feb 2024 09:36:05 +0000 Subject: [PATCH] More docs --- src/FactorGraphs/FactorGraphLayer.php | 2 -- src/GameInfo.php | 10 ++++++-- src/Numerics/GaussianDistribution.php | 34 ++++++++++++++++++++------- src/Player.php | 1 - 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/FactorGraphs/FactorGraphLayer.php b/src/FactorGraphs/FactorGraphLayer.php index 3b16f40..4b7ed59 100644 --- a/src/FactorGraphs/FactorGraphLayer.php +++ b/src/FactorGraphs/FactorGraphLayer.php @@ -36,8 +36,6 @@ abstract class FactorGraphLayer return $this->inputVariablesGroups; } - // HACK - public function getParentFactorGraph(): TrueSkillFactorGraph { return $this->parentFactorGraph; diff --git a/src/GameInfo.php b/src/GameInfo.php index 81d0c4d..9a01b73 100644 --- a/src/GameInfo.php +++ b/src/GameInfo.php @@ -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; diff --git a/src/Numerics/GaussianDistribution.php b/src/Numerics/GaussianDistribution.php index e0b012d..4c3598b 100644 --- a/src/Numerics/GaussianDistribution.php +++ b/src/Numerics/GaussianDistribution.php @@ -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); diff --git a/src/Player.php b/src/Player.php index 5eb2241..fcb7d6c 100644 --- a/src/Player.php +++ b/src/Player.php @@ -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;