class_docstr: GMM 1D distribution.
  
  Given a set of points, we create this object so that we
  can calculate likelihoods and generate samples from this
  1D Gaussian mixture model.
  
  Attributes
  ----------
  points : 1D array
      Set of points to create the GMM
  
  N : int
      Number of points to create the GMM
  
  min_limit : Optional[float], default : -inf
      Minimum limit for the distribution
  
  max_limit : Optional[float], default : inf
      Maximum limit for the distribution
  
  weights : Optional[1D array], default : array of ones
      Used to weight the points non-uniformly if required
class_docstr_tok: ["GMM","1D","distribution",".","Given","a","set","of","points",",","we","create","this","object","so","that","we","can","calculate","likelihoods","and","generate","samples","from","this","1D","Gaussian","mixture","model",".","Attributes","--","--","--","--","--","points",":","1D","array","Set","of","points","to","create","the","GMM","N",":","int","Number","of","points","to","create","the","GMM","min_limit",":","Optional","[","float","]",",","default",":","-inf","Minimum","limit","for","the","distribution","max_limit",":","Optional","[","float","]",",","default",":","inf","Maximum","limit","for","the","distribution","weights",":","Optional","[","1D","array","]",",","default",":","array","of","ones","Used","to","weight","the","points","non-uniformly","if","required"]
docstr: Sample the GMM distribution.
  
  Arguments
  ---------
  n : int
      Number of samples needed
  
  Returns
  -------
  1D array
      Samples from the distribution
docstr_tok: ["Sample","the","GMM","distribution",".","Arguments","--","--","--","--","-","n",":","int","Number","of","samples","needed","Returns","--","--","--","-","1D","array","Samples","from","the","distribution"]
code: def get_samples(self, n):
      """Sample the GMM distribution.
  
      Arguments
      ---------
      n : int
          Number of samples needed
  
      Returns
      -------
      1D array
          Samples from the distribution
      """
  
      normalized_w = self.weights / np.sum(self.weights)
      get_rand_index = st.rv_discrete(
          values=(range(self.N), normalized_w)
      ).rvs(size=n)
      samples = np.zeros(n)
      k = 0
      j = 0
      while k < n:
          i = get_rand_index[j]
          j = j + 1
          if j == n:
              get_rand_index = st.rv_discrete(
                  values=(range(self.N), normalized_w)
              ).rvs(size=n)
              j = 0
          v = np.random.normal(loc=self.points[i], scale=self.sigma[i])
          if v > self.max_limit or v < self.min_limit:
              continue
          else:
              samples[k] = v
              k = k + 1
              if k == n:
                  break
      return samples
  
file_path: brainiak/brainiak/hyperparamopt/hpo.py
imports: import logging
  import math
  import numpy
  from scipy.special import erf
  import scipy.stats
label_desc: Use image node_id 4 for calling the gmm_1d_distribution obj's underlying member method code with example usage: obj.get_samples(n) and returns: samples