newMessage = new GaussianDistribution($mean, sqrt($variance)); $newMessage = new Message( GaussianDistribution::fromPrecisionMean(0, 0), sprintf('message from %s to %s', $this, $variable) ); $this->createVariableToMessageBindingWithMessage($variable, $newMessage); } protected function updateMessageVariable(Message $message, Variable $variable): float { $oldMarginal = clone $variable->getValue(); $oldMessage = $message; $newMarginal = GaussianDistribution::fromPrecisionMean( $oldMarginal->getPrecisionMean() + $this->newMessage->getPrecisionMean() - $oldMessage->getValue()->getPrecisionMean(), $oldMarginal->getPrecision() + $this->newMessage->getPrecision() - $oldMessage->getValue()->getPrecision() ); $variable->setValue($newMarginal); $message->setValue($this->newMessage); return GaussianDistribution::subtract($oldMarginal, $newMarginal); } }