title: From Gaussian mixture to Gaussian and Uniform mixture
body: <p>The code below generates data for a 1d Gaussian mixture model:</p>
  <pre><code>from sklearn import mixture
  import matplotlib.pyplot as plt
  import numpy as np
  import matplotlib
  import matplotlib.ticker as tkr
  import scipy.stats as stats
  
  
  # create the data (note the two random.normal distributions)
  x = np.concatenate((np.random.normal(-2, 2, 1000),np.random.normal(0, 2, 1000)))
  
  f = np.ravel(x).astype(np.float)
  f=f.reshape(-1,1)
  g = mixture.GaussianMixture(n_components=2,covariance_type='full')
  g.fit(f)
  weights = g.weights_
  means = g.means_
  covars = g.covariances_
  
  plt.hist(f, bins=100, histtype='bar', density=True, ec='g', alpha=0.5)
  
  f_axis = f.copy().ravel()
  f_axis.sort()
  #plt.plot(f_axis,weights[0]*stats.norm.pdf(f_axis,means[0],np.sqrt(covars[0])).ravel(), c='red')
  
  plt.rcParams['agg.path.chunksize'] = 10000
  plt.show()
  </code></pre>
  <p>That looks like:
  <a href="https://i.stack.imgur.com/0KBhN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0KBhN.png" alt="enter image description here" /></a></p>
  <p>This code snippet provides us also with the estimated <strong>means</strong>, <strong>covariances</strong> and <strong>weights</strong> of the mixture model.</p>
  <p>If we change the <code>random.normal</code> to <code>random.uniform</code> for the sampling process:</p>
  <pre><code>x = np.concatenate((np.random.normal(-2, 2, 1000),np.random.uniform(0, 2, 1000)))
  </code></pre>
  <p>We obtain data that looks like:
  <a href="https://i.stack.imgur.com/4TFVz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4TFVz.png" alt="enter image description here" /></a></p>
  <p><strong>My first question is whether</strong> <code>g = mixture.GaussianMixture(n_components=2,covariance_type='full')</code> <strong>is a good option despite one of the distributions is not normal but rather uniform</strong>. I believe the answer is no, especially if we lower the samples available from the uniform distribution.</p>
  <p><strong>In this case, what can I possibly do to get relatively accurate estimates for the mean of the gaussian and the mixture weights?</strong></p>