class_docstr: Subclass of Bayesian GMMs (BGMM)
  that implements Variational Bayes estimation of the parameters
class_docstr_tok: ["Subclass","of","Bayesian","GMMs","(","BGMM",")","that","implements","Variational","Bayes","estimation","of","the","parameters"]
docstr: computation of evidence bound aka free energy
  
  Parameters
  ----------
  x array of shape (nb_samples,dim)
    the data from which evidence is computed
  like=None: array of shape (nb_samples, self.k), optional
             component-wise likelihood
             If None, it is recomputed
  verbose=0: verbosity model
  
  Returns
  -------
  ev (float) the computed evidence
docstr_tok: ["computation","of","evidence","bound","aka","free","energy","Parameters","--","--","--","--","--","x","array","of","shape","(","nb_samples",",","dim",")","the","data","from","which","evidence","is","computed","like=None",":","array","of","shape","(","nb_samples",",","self.k",")",",","optional","component-wise","likelihood","If","None",",","it","is","recomputed","verbose=0",":","verbosity","model","Returns","--","--","--","-","ev","(","float",")","the","computed","evidence"]
code: def evidence(self, x, like=None, verbose=0):
      """computation of evidence bound aka free energy
  
      Parameters
      ----------
      x array of shape (nb_samples,dim)
        the data from which evidence is computed
      like=None: array of shape (nb_samples, self.k), optional
                 component-wise likelihood
                 If None, it is recomputed
      verbose=0: verbosity model
  
      Returns
      -------
      ev (float) the computed evidence
      """
      from numpy.linalg import inv
      from scipy.special import psi
  
      tiny = 1.0e-15
      if like is None:
          like = self._Estep(x)
          like = (like.T / np.maximum(like.sum(1), tiny)).T
  
      pop = like.sum(0)[: self.k]
      pop = np.reshape(pop, (self.k, 1))
      spsi = psi(np.sum(self.weights))
      empmeans = np.dot(like.T[: self.k], x) / np.maximum(pop, tiny)
  
      F = 0
      # start with the average likelihood term
      for k in range(self.k):
          # compute the data-independent factor first
          Lav = psi(self.weights[k]) - spsi
          Lav -= (
              np.sum(like[:, k] * np.log(np.maximum(like[:, k], tiny)))
              / pop[k]
          )
          Lav -= 0.5 * self.dim * np.log(2 * np.pi)
          Lav += 0.5 * np.log(detsh(self.scale[k]))
          Lav += 0.5 * np.log(2) * self.dim
          for i in range(self.dim):
              Lav += 0.5 * psi((self.dof[k] - i) / 2)
          Lav -= self.dim * 0.5 / self.shrinkage[k]
          Lav *= pop[k]
          empcov = np.zeros((self.dim, self.dim))
          dx = x - empmeans[k]
          empcov = np.dot(dx.T, like[:, k : k + 1] * dx)
          Lav -= 0.5 * np.trace(
              np.dot(empcov, self.scale[k] * self.dof[k])
          )
          F += Lav
  
      # then the KL divergences
      prior_covariance = np.array(self._inv_prior_scale)
      covariance = np.array([inv(self.scale[k]) for k in range(self.k)])
      Dklw = 0
      Dklg = 0
      Dkld = dkl_dirichlet(self.weights, self.prior_weights)
      for k in range(self.k):
          Dklw += dkl_wishart(
              self.dof[k],
              covariance[k],
              self.prior_dof[k],
              prior_covariance[k],
          )
          nc = self.scale[k] * (self.dof[k] * self.shrinkage[k])
          nc0 = self.scale[k] * (self.dof[k] * self.prior_shrinkage[k])
          Dklg += dkl_gaussian(
              self.means[k], nc, self.prior_means[k], nc0
          )
      Dkl = Dkld + Dklg + Dklw
      if verbose:
          print("Lav", F, "Dkl", Dkld, Dklg, Dklw)
      F -= Dkl
      return F
  
imports: import math
  import numpy
  import numpy.random
  from scipy.linalg import cholesky, eigvalsh, inv
  from scipy.special import gammaln
  from .gmm import GMM
  from .utils import kmeans
label_desc: Use image node_id 3 for calling the VBGMM obj's underlying member method code with example usage: obj.evidence(x, like, verbose) and returns: F