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: sample the indicator and parameters
  the average values for weights,means, precisions are returned
  
  Parameters
  ----------
  x = array of shape (nb_samples,dim)
    the data from which bic is computed
  niter=1: number of iterations
  
  Returns
  -------
  weights: array of shape (self.k)
  means: array of shape (self.k,self.dim)
  precisions:  array of shape (self.k,self.dim,self.dim)
               or (self.k, self.dim)
               these are the average parameters across samplings
  
  Notes
  -----
  All this makes sense only if no label switching as occurred so this is
  wrong in general (asymptotically).
  
  fix: implement a permutation procedure for components identification
docstr_tok: ["sample","the","indicator","and","parameters","the","average","values","for","weights",",","means",",","precisions","are","returned","Parameters","--","--","--","--","--","x","=","array","of","shape","(","nb_samples",",","dim",")","the","data","from","which","bic","is","computed","niter=1",":","number","of","iterations","Returns","--","--","--","-","weights",":","array","of","shape","(","self.k",")","means",":","array","of","shape","(","self.k",",","self.dim",")","precisions",":","array","of","shape","(","self.k",",","self.dim",",","self.dim",")","or","(","self.k",",","self.dim",")","these","are","the","average","parameters","across","samplings","Notes","--","--","-","All","this","makes","sense","only","if","no","label","switching","as","occurred","so","this","is","wrong","in","general","(","asymptotically",")",".","fix",":","implement","a","permutation","procedure","for","components","identification"]
code: def sample_and_average(self, x, niter=1, verbose=0):
      """
      sample the indicator and parameters
      the average values for weights,means, precisions are returned
  
      Parameters
      ----------
      x = array of shape (nb_samples,dim)
        the data from which bic is computed
      niter=1: number of iterations
  
      Returns
      -------
      weights: array of shape (self.k)
      means: array of shape (self.k,self.dim)
      precisions:  array of shape (self.k,self.dim,self.dim)
                   or (self.k, self.dim)
                   these are the average parameters across samplings
  
      Notes
      -----
      All this makes sense only if no label switching as occurred so this is
      wrong in general (asymptotically).
  
      fix: implement a permutation procedure for components identification
      """
      aprec = np.zeros(np.shape(self.precisions))
      aweights = np.zeros(np.shape(self.weights))
      ameans = np.zeros(np.shape(self.means))
  
      for i in range(niter):
          like = self.likelihood(x)
          z = self.sample_indicator(like)
          self.update(x, z)
          aprec += self.precisions
          aweights += self.weights
          ameans += self.means
      aprec /= niter
      ameans /= niter
      aweights /= niter
      return aweights, ameans, aprec
  
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 13 for calling the BGMM obj's underlying member method code with example usage: obj.sample_and_average(x, niter, verbose) and returns: aweights,  ameans,  aprec