class_docstr: This class implements Bayesian GMMs
  
  this class contains the following fields
  k: int,
     the number of components in the mixture
  dim: int,
       the dimension of the data
  means: array of shape (k, dim)
         all the means of the components
  precisions: array of shape (k, dim, dim)
              the precisions of the components
  weights: array of shape (k):
           weights of the mixture
  shrinkage: array of shape (k):
             scaling factor of the posterior precisions on the mean
  dof: array of shape (k)
       the degrees of freedom of the components
  prior_means: array of shape (k, dim):
               the prior on the components means
  prior_scale: array of shape (k, dim):
               the prior on the components precisions
  prior_dof: array of shape (k):
              the prior on the dof (should be at least equal to dim)
  prior_shrinkage: array of shape (k):
                   scaling factor of the prior precisions on the mean
  prior_weights: array of shape (k)
                 the prior on the components weights
  shrinkage: array of shape (k):
             scaling factor of the posterior precisions on the mean
  dof : array of shape (k): the posterior dofs
  
  fixme
  -----
  only 'full' precision is supported
class_docstr_tok: ["This","class","implements","Bayesian","GMMs","this","class","contains","the","following","fields","k",":","int",",","the","number","of","components","in","the","mixture","dim",":","int",",","the","dimension","of","the","data","means",":","array","of","shape","(","k",",","dim",")","all","the","means","of","the","components","precisions",":","array","of","shape","(","k",",","dim",",","dim",")","the","precisions","of","the","components","weights",":","array","of","shape","(","k",")",":","weights","of","the","mixture","shrinkage",":","array","of","shape","(","k",")",":","scaling","factor","of","the","posterior","precisions","on","the","mean","dof",":","array","of","shape","(","k",")","the","degrees","of","freedom","of","the","components","prior_means",":","array","of","shape","(","k",",","dim",")",":","the","prior","on","the","components","means","prior_scale",":","array","of","shape","(","k",",","dim",")",":","the","prior","on","the","components","precisions","prior_dof",":","array","of","shape","(","k",")",":","the","prior","on","the","dof","(","should","be","at","least","equal","to","dim",")","prior_shrinkage",":","array","of","shape","(","k",")",":","scaling","factor","of","the","prior","precisions","on","the","mean","prior_weights",":","array","of","shape","(","k",")","the","prior","on","the","components","weights","shrinkage",":","array","of","shape","(","k",")",":","scaling","factor","of","the","posterior","precisions","on","the","mean","dof",":","array","of","shape","(","k",")",":","the","posterior","dofs","fixme","--","--","-","only","'full","'","precision","is","supported"]
docstr: Compute the probability of the current parameters of self
  given x and z
  
  Parameters
  ----------
  x: array of shape (nb_samples, dim),
     the data from which bic is computed
  z: array of shape (nb_samples), type = np.int_,
     the corresponding classification
  perm: array ok shape(nperm, self.k),typ=np.int_, optional
        all permutation of z under which things will be recomputed
        By default, no permutation is performed
docstr_tok: ["Compute","the","probability","of","the","current","parameters","of","self","given","x","and","z","Parameters","--","--","--","--","--","x",":","array","of","shape","(","nb_samples",",","dim",")",",","the","data","from","which","bic","is","computed","z",":","array","of","shape","(","nb_samples",")",",","type","=","np.int_",",","the","corresponding","classification","perm",":","array","ok","shape","(","nperm",",","self.k",")",",","typ=np.int_",",","optional","all","permutation","of","z","under","which","things","will","be","recomputed","By","default",",","no","permutation","is","performed"]
code: def conditional_posterior_proba(self, x, z, perm=None):
      """
      Compute the probability of the current parameters of self
      given x and z
  
      Parameters
      ----------
      x: array of shape (nb_samples, dim),
         the data from which bic is computed
      z: array of shape (nb_samples), type = np.int_,
         the corresponding classification
      perm: array ok shape(nperm, self.k),typ=np.int_, optional
            all permutation of z under which things will be recomputed
            By default, no permutation is performed
      """
      pop = self.pop(z)
      rpop = (pop + (pop == 0)).astype(np.float64)
      dof = self.prior_dof + pop + 1
      shrinkage = self.prior_shrinkage + pop
      weights = pop + self.prior_weights
  
      # initialize the porsterior proba
      if perm is None:
          pp = dirichlet_eval(self.weights, weights)
      else:
          pp = np.array(
              [dirichlet_eval(self.weights[pj], weights) for pj in perm]
          )
  
      for k in range(self.k):
          m1 = np.sum(x[z == k], 0)
  
          # 0. Compute the empirical means
          empmeans = m1 / rpop[k]
  
          # 1. the precisions
          dx = np.reshape(x[z == k] - empmeans, (pop[k], self.dim))
          dm = np.reshape(empmeans - self.prior_means[k], (1, self.dim))
          addcov = np.dot(dm.T, dm) * self.prior_shrinkage[k]
  
          covariance = (
              self._inv_prior_scale[k] + np.dot(dx.T, dx) + addcov
          )
          scale = inv(covariance)
          _dets = detsh(scale)
  
          # 2. the means
          means = m1 + self.prior_means[k] * self.prior_shrinkage[k]
          means /= shrinkage[k]
  
          # 4. update the posteriors
          if perm is None:
              pp *= wishart_eval(
                  dof[k],
                  scale,
                  self.precisions[k],
                  dV=_dets,
                  dW=self._detp[k],
                  piV=covariance,
              )
          else:
              for j, pj in enumerate(perm):
                  pp[j] *= wishart_eval(
                      dof[k],
                      scale,
                      self.precisions[pj[k]],
                      dV=_dets,
                      dW=self._detp[pj[k]],
                      piV=covariance,
                  )
  
          mp = scale * shrinkage[k]
          _dP = _dets * shrinkage[k] ** self.dim
          if perm is None:
              pp *= normal_eval(means, mp, self.means[k], dP=_dP)
          else:
              for j, pj in enumerate(perm):
                  pp[j] *= normal_eval(
                      means, mp, self.means[pj[k]], dP=_dP
                  )
  
      return pp
  
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 15 for calling the BGMM obj's underlying member method code with example usage: obj.conditional_posterior_proba(x, z, perm) and returns: pp