parameters: (samples, ncomponents=2)
return_statement: return params
docstring: Given a numpy array of floating point samples, fit a gaussian mixture model.
docstring_summary: Given a numpy array of floating point samples, fit a gaussian mixture model.
docstring_tokens: Given a numpy array of floating point samples fit a gaussian mixture model .
function: def fit_gmm(samples, ncomponents=2):
      """Given a numpy array of floating point samples, fit a gaussian mixture model."""
      # assume samples is of shape (NSAMPLES,); unsqueeze to (NSAMPLES,1) and train a GMM:
      gmm = GaussianMixture(n_components=ncomponents)
      gmm.fit(samples.reshape(-1,1))
      # return params of GMM in [(coeff, mu, sigma)] format:
      params = [(gmm.weights_[c], gmm.means_[c][0], gmm.covariances_[c][0][0]) for c in range(ncomponents)]
      return params
function_tokens: def fit_gmm ( samples , ncomponents = 2 ) : # assume samples is of shape (NSAMPLES,); unsqueeze to (NSAMPLES,1) and train a GMM: gmm = GaussianMixture ( n_components = ncomponents ) gmm . fit ( samples . reshape ( - 1 , 1 ) ) # return params of GMM in [(coeff, mu, sigma)] format: params = [ ( gmm . weights_ [ c ] , gmm . means_ [ c ] [ 0 ] , gmm . covariances_ [ c ] [ 0 ] [ 0 ] ) for c in range ( ncomponents ) ] return params