def logNormalization(self): marginal = self._variables[0].value message = self._messages[0].value messageFromVariable = marginal/message mean = messageFromVariable.mean std = messageFromVariable.standardDeviation z = cumulativeTo((self._epsilon - mean) / std) - cumulativeTo((-1.0 * self._epsilon - mean) / std) return -1.0 * logProductNormalization(messageFromVariable, message) + log(z)
def logNormalization(self): marginal = self._variables[0].value message = self._messages[0].value messageFromVariable = marginal/message return -1.0*logProductNormalization(messageFromVariable, message) + log(cumulativeTo((messageFromVariable.mean - self._epsilon) / messageFromVariable.standardDeviation))
def test_cumulativeToTests(self): desired = 0.691462 actual = cumulativeTo(0.5) self.assertAlmostEqual(first=desired, second=actual, delta=self.__errorTolerance)