title: Curve_Fit not returning expected values
body: <p>I have code here that draws from two gaussian distributions with an equal number of points.</p>
  
  <p>Ultimately, I want to simulate noise but I'm trying to see why if I have two gaussians with means that are really far off from each other, my curve_fit should return their average mean value. It doesn't do that.</p>
  
  <pre><code>import numpy as np
  from scipy.optimize import curve_fit
  import matplotlib.pyplot as plt
  import gauss
  
  N_tot = 1000
  # Draw from the major gaussian. Note the number N. It is
  # the main parameter in obtaining your estimators.
  mean = 0; sigma = 1; var = sigma**2; N = 100
  A = 1/np.sqrt((2*np.pi*var))
  points = gauss.draw_1dGauss(mean,var,N)
  
  # Now draw from a minor gaussian. Note Np
  meanp = 10; sigmap = 1; varp = sigmap**2; Np = N_tot-N
  pointsp = gauss.draw_1dGauss(meanp,varp,Np)
  Ap = 1/np.sqrt((2*np.pi*varp))      
  
  # Now implement the sum of the draws by concatenating the two arrays.
  points_tot = np.array(points.tolist()+pointsp.tolist())
  bins_tot = len(points_tot)/5
  hist_tot, bin_edges_tot = np.histogram(points_tot,bins_tot,density=True)
  bin_centres_tot = (bin_edges_tot[:-1] + bin_edges_tot[1:])/2.0
  
  # Initial guess
  p0 = [A, mean, sigma]
  
  # Result of the fit
  coeff, var_matrix = curve_fit(gauss.gaussFun, bin_centres_tot, hist_tot, p0=p0)
  
  # Get the fitted curve
  hist_fit = gauss.gaussFun(bin_centres, *coeff)
  plt.figure(5); plt.title('Gaussian Estimate')
  plt.suptitle('Gaussian Parameters: Mu = '+ str(coeff[1]) +' , Sigma = ' + str(coeff[2]) + ', Amplitude = ' + str(coeff[0]))
  plt.plot(bin_centres,hist_fit)
  plt.draw()        
  
  # Error on the estimates
  error_parameters = np.sqrt(np.array([var_matrix[0][0],var_matrix[1][1],var_matrix[2][2]]))
  </code></pre>
  
  <p>The returned parameters are still centered about 0 and I'm not sure why. It should be centered around 10.</p>
  
  <p>Edit: Changed the integer division portions but still not returning good fit value.
  I should get a mean of about ~10 since most of my points are being drawn from that distribution (i.e. the minor distribution)</p>