class_docstr: Extreme Deconvolution
  
  Fit an extreme deconvolution (XD) model to the data
  
  Parameters
  ----------
  n_components: integer
      number of gaussian components to fit to the data
  max_iter: integer (optional)
      number of EM iterations to perform (default=100)
  tol: float (optional)
      stopping criterion for EM iterations (default=1E-5)
  
  Notes
  -----
  This implementation follows Bovy et al. arXiv 0905.2979
class_docstr_tok: ["Extreme","Deconvolution","Fit","an","extreme","deconvolution","(","XD",")","model","to","the","data","Parameters","--","--","--","--","--","n_components",":","integer","number","of","gaussian","components","to","fit","to","the","data","max_iter",":","integer","(","optional",")","number","of","EM","iterations","to","perform","(","default=100",")","tol",":","float","(","optional",")","stopping","criterion","for","EM","iterations","(","default=1E-5",")","Notes","--","--","-","This","implementation","follows","Bovy","et","al",".","arXiv","0905.2979"]
docstr: Perform the E-step (eq 16 of Bovy et al)
docstr_tok: ["Perform","the","E-step","(","eq","16","of","Bovy","et","al",")"]
code: def _EMstep(self, X, Xerr):
      """
      Perform the E-step (eq 16 of Bovy et al)
      """
      n_samples, n_features = X.shape
  
      X = X[:, np.newaxis, :]
      Xerr = Xerr[:, np.newaxis, :, :]
  
      w_m = X - self.mu
  
      T = Xerr + self.V
  
      # ------------------------------------------------------------
      #  compute inverse of each covariance matrix T
      Tshape = T.shape
      T = T.reshape(
          [n_samples * self.n_components, n_features, n_features]
      )
      Tinv = np.array(
          [linalg.inv(T[i]) for i in range(T.shape[0])]
      ).reshape(Tshape)
      T = T.reshape(Tshape)
  
      # ------------------------------------------------------------
      #  evaluate each mixture at each point
      N = np.exp(log_multivariate_gaussian(X, self.mu, T, Vinv=Tinv))
  
      # ------------------------------------------------------------
      #  E-step:
      #   compute q_ij, b_ij, and B_ij
      q = (N * self.alpha) / np.dot(N, self.alpha)[:, None]
  
      tmp = np.sum(Tinv * w_m[:, :, np.newaxis, :], -1)
      b = self.mu + np.sum(self.V * tmp[:, :, np.newaxis, :], -1)
  
      tmp = np.sum(
          Tinv[:, :, :, :, np.newaxis] * self.V[:, np.newaxis, :, :], -2
      )
      B = self.V - np.sum(
          self.V[:, :, :, np.newaxis] * tmp[:, :, np.newaxis, :, :], -2
      )
  
      # ------------------------------------------------------------
      #  M-step:
      #   compute alpha, m, V
      qj = q.sum(0)
  
      self.alpha = qj / n_samples
  
      self.mu = np.sum(q[:, :, np.newaxis] * b, 0) / qj[:, np.newaxis]
  
      m_b = self.mu - b
      tmp = m_b[:, :, np.newaxis, :] * m_b[:, :, :, np.newaxis]
      tmp += B
      tmp *= q[:, :, np.newaxis, np.newaxis]
      self.V = tmp.sum(0) / qj[:, np.newaxis, np.newaxis]
  
file_path: astroML/astroML/density_estimation/xdeconv.py
imports: from time import time
  import numpy
  from scipy import linalg
  from sklearn.base import BaseEstimator
  from sklearn.mixture import GaussianMixture
  from sklearn.utils import check_random_state
  from ..utils import log_multivariate_gaussian
label_desc: Use image node_id 5 for calling the XDGMM obj's underlying member method code with example usage: obj._EMstep(X, Xerr) without return types