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"]
code: def sample(self, size=1, random_state=None):
      if random_state is None:
          random_state = self.random_state
      rng = check_random_state(random_state)  # noqa: F841
      shape = tuple(np.atleast_1d(size)) + (self.mu.shape[1],)
      npts = np.prod(size)  # noqa: F841
  
      alpha_cs = np.cumsum(self.alpha)
      r = np.atleast_1d(np.random.random(size))
      r.sort()
  
      ind = r.searchsorted(alpha_cs)
      ind = np.concatenate(([0], ind))
      if ind[-1] != size:
          ind[-1] = size
  
      draw = np.vstack(
          [
              np.random.multivariate_normal(
                  self.mu[i], self.V[i], (ind[i + 1] - ind[i],)
              )
              for i in range(len(self.alpha))
          ]
      )
  
      return draw.reshape(shape)
  
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 6 for calling the XDGMM obj's underlying member method code with example usage: obj.sample(size, random_state) and returns: draw