def log_z(self) -> float:
    'Calculates logarithm of the partition function.'
    ans = 0.0
    for i in range(self.nrVars):
        ans += ((1.0 - len(self.nbV[i])) * self._belief_v(i).p.entropy())
    for ii in range(self.nrFactors):
        ans -= dist_kl(self._belief_f(ii).p, self.factors[ii].p)
    return ans
Calculates logarithm of the partition function.
def log_z(self) -> float:
    
    ans = 0.0
    for i in range(self.nrVars):
        ans += ((1.0 - len(self.nbV[i])) * self._belief_v(i).p.entropy())
    for ii in range(self.nrFactors):
        ans -= dist_kl(self._belief_f(ii).p, self.factors[ii].p)
    return ans