parameters: (self, n_samples=1)
return_statement: return (X, y)
docstring: Generate random samples from the fitted Gaussian distribution.
  
          Parameters
          ----------
          n_samples : int, optional
              Number of samples to generate. Defaults to 1.
  
          Returns
          -------
          X : array, shape (n_samples, n_features)
              Randomly generated sample
  
          y : array, shape (nsamples,)
              Component labels
docstring_summary: Generate random samples from the fitted Gaussian distribution.
docstring_tokens: Generate random samples from the fitted Gaussian distribution .
function: def sample(self, n_samples=1):
          """Generate random samples from the fitted Gaussian distribution.
  
          Parameters
          ----------
          n_samples : int, optional
              Number of samples to generate. Defaults to 1.
  
          Returns
          -------
          X : array, shape (n_samples, n_features)
              Randomly generated sample
  
          y : array, shape (nsamples,)
              Component labels
  
          """
          check_is_fitted(self)
  
          if n_samples < 1:
              raise ValueError(
                  "Invalid value for 'n_samples': %d . The sampling requires at "
                  "least one sample." % (self.n_components))
  
          _, n_features = self.means_.shape
          rng = check_random_state(self.random_state)
          n_samples_comp = rng.multinomial(n_samples, self.weights_)
  
          if self.covariance_type == 'full':
              X = np.vstack([
                  rng.multivariate_normal(mean, covariance, int(sample))
                  for (mean, covariance, sample) in zip(
                      self.means_, self.covariances_, n_samples_comp)])
          elif self.covariance_type == "tied":
              X = np.vstack([
                  rng.multivariate_normal(mean, self.covariances_, int(sample))
                  for (mean, sample) in zip(
                      self.means_, n_samples_comp)])
          else:
              X = np.vstack([
                  mean + rng.randn(sample, n_features) * np.sqrt(covariance)
                  for (mean, covariance, sample) in zip(
                      self.means_, self.covariances_, n_samples_comp)])
  
          y = np.concatenate([np.full(sample, j, dtype=int)
                             for j, sample in enumerate(n_samples_comp)])
  
          return (X, y)
function_tokens: def sample ( self , n_samples = 1 ) : check_is_fitted ( self ) if n_samples < 1 : raise ValueError ( "Invalid value for 'n_samples': %d . The sampling requires at " "least one sample." % ( self . n_components ) ) _ , n_features = self . means_ . shape rng = check_random_state ( self . random_state ) n_samples_comp = rng . multinomial ( n_samples , self . weights_ ) if self . covariance_type == 'full' : X = np . vstack ( [ rng . multivariate_normal ( mean , covariance , int ( sample ) ) for ( mean , covariance , sample ) in zip ( self . means_ , self . covariances_ , n_samples_comp ) ] ) elif self . covariance_type == "tied" : X = np . vstack ( [ rng . multivariate_normal ( mean , self . covariances_ , int ( sample ) ) for ( mean , sample ) in zip ( self . means_ , n_samples_comp ) ] ) else : X = np . vstack ( [ mean + rng . randn ( sample , n_features ) * np . sqrt ( covariance ) for ( mean , covariance , sample ) in zip ( self . means_ , self . covariances_ , n_samples_comp ) ] ) y = np . concatenate ( [ np . full ( sample , j , dtype = int ) for j , sample in enumerate ( n_samples_comp ) ] ) return ( X , y )