class_docstr: Standard GMM.
  
  this class contains the following members
  k (int): the number of components in the mixture
  dim (int): is the dimension of the data
  prec_type = 'full' (string) is the parameterization
            of the precisions/covariance matrices:
            either 'full' or 'diagonal'.
  means: array of shape (k,dim):
        all the means (mean parameters) of the components
  precisions: array of shape (k,dim,dim):
             the precisions (inverse covariance matrix) of the components
  weights: array of shape(k): weights of the mixture
  
  fixme
  -----
  no copy method
class_docstr_tok: ["Standard","GMM",".","this","class","contains","the","following","members","k","(","int",")",":","the","number","of","components","in","the","mixture","dim","(","int",")",":","is","the","dimension","of","the","data","prec_type","=","'full","'","(","string",")","is","the","parameterization","of","the","precisions\/covariance","matrices",":","either","'full","'","or","'diagonal","'",".","means",":","array","of","shape","(","k",",","dim",")",":","all","the","means","(","mean","parameters",")","of","the","components","precisions",":","array","of","shape","(","k",",","dim",",","dim",")",":","the","precisions","(","inverse","covariance","matrix",")","of","the","components","weights",":","array","of","shape","(","k",")",":","weights","of","the","mixture","fixme","--","--","-","no","copy","method"]
docstr: M step regularized according to the procedure of
  Fraley et al. 2007
  
  Parameters
  ----------
  x: array of shape(n_samples,self.dim)
     the data from which the model is estimated
  like: array of shape(n_samples,self.k)
     the likelihood of the data under each class
docstr_tok: ["M","step","regularized","according","to","the","procedure","of","Fraley","et","al",".","2007","Parameters","--","--","--","--","--","x",":","array","of","shape","(","n_samples",",","self.dim",")","the","data","from","which","the","model","is","estimated","like",":","array","of","shape","(","n_samples",",","self.k",")","the","likelihood","of","the","data","under","each","class"]
code: def _Mstep(self, x, like):
      """
      M step regularized according to the procedure of
      Fraley et al. 2007
  
      Parameters
      ----------
      x: array of shape(n_samples,self.dim)
         the data from which the model is estimated
      like: array of shape(n_samples,self.k)
         the likelihood of the data under each class
      """
      from numpy.linalg import pinv
  
      tiny = 1.0e-15
      pop = self.pop(like)
      sl = np.maximum(tiny, np.sum(like, 1))
      like = (like.T / sl).T
  
      # shrinkage,weights,dof
      self.weights = self.prior_weights + pop
      self.weights = self.weights / self.weights.sum()
  
      # reshape
      pop = np.reshape(pop, (self.k, 1))
      prior_shrinkage = self.prior_shrinkage
      shrinkage = pop + prior_shrinkage
  
      # means
      means = np.dot(like.T, x) + self.prior_means * prior_shrinkage
      self.means = means / shrinkage
  
      # precisions
      empmeans = np.dot(like.T, x) / np.maximum(pop, tiny)
      empcov = np.zeros(np.shape(self.precisions))
  
      if self.prec_type == "full":
          for k in range(self.k):
              dx = x - empmeans[k]
              empcov[k] = np.dot(dx.T, like[:, k : k + 1] * dx)
          # covariance
          covariance = np.array(
              [pinv(self.prior_scale[k]) for k in range(self.k)]
          )
          covariance += empcov
          dx = np.reshape(
              empmeans - self.prior_means, (self.k, self.dim, 1)
          )
          addcov = np.array(
              [np.dot(dx[k], dx[k].T) for k in range(self.k)]
          )
          apms = np.reshape(
              prior_shrinkage * pop / shrinkage, (self.k, 1, 1)
          )
          covariance += addcov * apms
          dof = self.prior_dof + pop + self.dim + 2
          covariance /= np.reshape(dof, (self.k, 1, 1))
  
          # precision
          self.precisions = np.array(
              [pinv(covariance[k]) for k in range(self.k)]
          )
      else:
          for k in range(self.k):
              dx = x - empmeans[k]
              empcov[k] = np.sum(dx**2 * like[:, k : k + 1], 0)
          # covariance
          covariance = np.array(
              [1.0 / self.prior_scale[k] for k in range(self.k)]
          )
          covariance += empcov
          dx = np.reshape(
              empmeans - self.prior_means, (self.k, self.dim, 1)
          )
          addcov = np.array(
              [np.sum(dx[k] ** 2, 0) for k in range(self.k)]
          )
          apms = np.reshape(
              prior_shrinkage * pop / shrinkage, (self.k, 1)
          )
          covariance += addcov * apms
          dof = self.prior_dof + pop + self.dim + 2
          covariance /= np.reshape(dof, (self.k, 1))
  
          # precision
          self.precisions = np.array(
              [1.0 / covariance[k] for k in range(self.k)]
          )
  
imports: import numpy
  from scipy.linalg import eigvalsh
label_desc: Use image node_id 17 for calling the GMM obj's underlying member method code with example usage: obj._Mstep(x, like) without return types