title: Fit gaussian mixture model to PDF
body: <p>As the title says I want to fit a gaussian mixture model to a given PDF. So, suppose I know the probability density distribution of my data and let's just say it is discretised like that:</p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  
  
  def gaussian(gx, amp, mu, sig):
      return amp * np.exp(-np.power(gx - mu, 2.) / (2 * np.power(sig, 2.)))
  
  x = np.linspace(-10, 10, 1000)
  g1 = gaussian(gx=x, amp=2, mu=-3, sig=1)
  g2 = gaussian(gx=x, amp=1, mu=4, sig=0.5)
  pdf = (g1 + g2) / np.nansum(g1 + g2)
  
  plt.scatter(x, pdf)
  plt.show()
  </code></pre>
  
  <p>this gives us a nice pdf with two separat gaussian peaks. Now I simply want to fit a gaussian mixture model to the pdf. The way I understand scikit works is that you don't fit the model to a pdf, but to data samples. So, in principle I would have to take the pdf, draw samples from it and then fit gaussian mixture models, but I already have the pdf and just want to describe it with a mixture of gaussians...</p>
  
  <p>any ideas?</p>