def free_energy(self, beta=0.0): q_ = self.ppm[self.mask] f = np.sum(q_*np.log(np.maximum(q_/self.ref_, TINY))) if beta > 0.0: print(' ... Concensus correction') fc = _concensus(self.ppm, np.array(self.mask, dtype='int')) print fc f = f - .5*beta*fc return f
def free_energy(self): """ Compute the free energy defined as: F(q, theta) = int q(x) log q(x)/p(x,y/theta) dx associated with input parameters mu, sigma and beta (up to an ignored constant). """ q_ = self.ppm[self.mask] # Entropy term f = np.sum(q_*np.log(np.maximum(q_/self.ref_, TINY))) # Interaction term if self.beta > 0.0: print(' ... Concensus correction') fc = _concensus(self.ppm, np.array(self.mask, dtype='int')) f -= .5*self.beta*fc return f