title: How to represent 1D vector as sum of Gaussian curves with scipy/numpy?
body: <p><strong>UPD: Thanks, it works.</strong></p>
  
  <p>I have an 1D-vector, which represents a histogram. It looks like sum of few gaussian functions:
  <a href="https://i.stack.imgur.com/qjxGV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qjxGV.png" alt="enter image description here"></a> </p>
  
  <p>I've found <code>curve_fit</code> sample code on SO, but don't know how to modify it to receive more gaussian tuples (mu, sigma). I've heard 'curve_fit' optimizes only one function (in this case one gaussian curve).</p>
  
  <pre><code>import numpy as np
  from scipy.optimize import curve_fit
  import matplotlib.pyplot as plt
  
  def estimate_sigma(hist):
      bin_edges = np.arange(len(hist))
      bin_centres = bin_edges + 0.5
  
      # Define model function to be used to fit to the data above:
      def gauss(x, *p):
          A, mu, sigma = p
          return A*numpy.exp(-(x-mu)**2/(2.*sigma**2))
  
      # p0 is the initial guess for the fitting coefficients (A, mu and sigma above)
      p0 = [1., 0., 1.]
  
      coeff, var_matrix = curve_fit(gauss, bin_centres, hist, p0=p0)
  
      # Get the fitted curve
      hist_fit = gauss(bin_centres, *coeff)
  
      plt.plot(bin_centres, hist, label='Test data')
      plt.plot(bin_centres, hist_fit, label='Fitted data')
  
      print 'Fitted mean = ', coeff[1]
      coeff2 =coeff[2]
      print 'Fitted standard deviation = ', coeff2
  
      plt.show()
  </code></pre>
  
  <p>This functions finds one gaussian curve, while visually there are 3 or 4 of them:
  <a href="https://i.stack.imgur.com/wS2OO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wS2OO.png" alt="enter image description here"></a> </p>
  
  <p>Please, could you advice some numpy/scipy functions to achieve gmm representation of <code>1D vector</code> in form <code>([m1, sigma1],[m2, sigma2],..,[mN,sigmaN])</code>? </p>