docstr: 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).
docstr_tok: ["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",")","."]
code: def free_energy(self, ppm=None):
      """
      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).
      """
      if ppm is None:
          ppm = self.ppm
      q = ppm[self.mask]
      # Entropy term
      lef = self.log_external_field()
      f1 = np.sum(q * (log(q) - lef))
      # Interaction term
      if self.beta > 0.0:
          f2 = self.beta * _interaction_energy(
              ppm, self.XYZ, self.U, self.ngb_size
          )
      else:
          f2 = 0.0
      return f1 + f2
  
file_path: nipy/nipy/algorithms/segmentation/segmentation.py
imports: import numpy
  from ._segmentation import _interaction_energy, _ve_step
label_desc: Use image node_id 9 for calling the Segmentation obj's underlying member method code with example usage: obj.free_energy(ppm) and returns: unknown