From 467d508f005d63975833d4dc6da27b40d6c507e8 Mon Sep 17 00:00:00 2001 From: Jeff Moser Date: Sun, 26 Sep 2010 18:32:18 -0400 Subject: [PATCH] Updated some weighted sum arrays --- .../Factors/GaussianWeightedSumFactor.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/PHPSkills/TrueSkill/Factors/GaussianWeightedSumFactor.php b/PHPSkills/TrueSkill/Factors/GaussianWeightedSumFactor.php index b8f6a8b..977a2cf 100644 --- a/PHPSkills/TrueSkill/Factors/GaussianWeightedSumFactor.php +++ b/PHPSkills/TrueSkill/Factors/GaussianWeightedSumFactor.php @@ -50,9 +50,10 @@ class GaussianWeightedSumFactor extends GaussianFactor $variablesToSumLength = count($variablesToSum); // 0..n-1 + $this->_variableIndexOrdersForWeights[0] = array(); for($i = 0; $i < ($variablesToSumLength + 1); $i++) { - $this->_variableIndexOrdersForWeights[] = $i; + $this->_variableIndexOrdersForWeights[0][] = $i; } // The rest move the variables around and divide out the constant. @@ -62,14 +63,15 @@ class GaussianWeightedSumFactor extends GaussianFactor $weightsLength = $variableWeightsLength + 1; for ($weightsIndex = 1; $weightsIndex < $weightsLength; $weightsIndex++) - { - $this->_weights[$weightsIndex] = array(); + { + $currentWeights = array(); + $this->_weights[$weightsIndex] = &$currentWeights; $variableIndices = array(); - $variableIndices[] = $weightsIndex; + $variableIndices[0] = $weightsIndex; $currentWeightsSquared = array(); - $this->_WeightsSquared[$weightsIndex] = &$currentWeightsSquared; + $this->_weightsSquared[$weightsIndex] = &$currentWeightsSquared; // keep a single variable to keep track of where we are in the array. // This is helpful since we skip over one of the spots @@ -111,7 +113,7 @@ class GaussianWeightedSumFactor extends GaussianFactor } $currentWeights[$currentDestinationWeightIndex] = $finalWeight; $currentWeightsSquared[$currentDestinationWeightIndex] = square($finalWeight); - $variableIndices[count($variableIndices) - 1] = 0; + $variableIndices[count($variableWeights)] = 0; $this->_variableIndexOrdersForWeights[] = &$variableIndices; }