title: scipy curve_fit returning initial parameter estimates
body: <p>I am trying to use scipy curve_fit to fit a gaussian function to my data, for which there are MANY helpful examples on the web, and I have tried to get several to work, but to no avail.  I wrote a simple script using made-up data to diagnose the problem.  In short, curve_fit is not doing any fitting, the function is just returning the initial parameter values, no matter how close they are to the real numbers.  Here is the code for the simple script:</p>
  
  <pre><code># -*- coding: utf-8 -*-
  import numpy
  import matplotlib.pyplot as plt
  import matplotlib.mlab as mlab
  from scipy import optimize
  
  ##Fit
  def Fit( datax, datay ):    
      # define your function:
      def f(x, *p): 
          p = m, b     
          return m*numpy.asarray(x) + b
      m = 0.4
      b = 2.4
      p_init = [m, b]
      Initial_model = f(datax, [m, b])    
      plt.plot(datax, Initial_model, label='Initial Model')
      plt.title("Initial Model")
  #    plt.title('Initial Model')
  #    plt.show()
     # fit! (given that data is an array with the data to fit)
      print optimize.curve_fit(f, datax, datay, p_init)
      coeff, var_matrix = optimize.curve_fit(f, datax, datay, p_init)
      global fit
      fit = f(datax, *coeff)
      plt.plot(datax, fit, 'r-')
      plt.show()
      print 'Fitted slope 1 = ', coeff[0]
      print 'Fitted intercept 1 = ', coeff[1]
      return fit
  
  ##Plot
  def Plot( datax, datay, fit ):
      fig = plt.figure()
      ax = fig.add_subplot(111)
      plt.plot(datax, datay, 'b*')
      l = ax.plot( datax, fit, 'r-', linewidth=2)
      ax.set_xlabel('Rate')
      ax.set_ylabel('Return')
      ax.set_title("Test")
      ax.autoscale(enable=True, axis='both', tight=None)
      ax.grid(True)
      plt.show()
  
  ##data
  datax = numpy.array([7.02, 20.06, 13.78, 16.92, 10.17], dtype=numpy.float64)
  datay = numpy.array([5.14, 10.66, 8.44, 9.64, 6.79], dtype=numpy.float64)
  
  ##analyze
  Fit( datax, datay )
  Plot( datax, datay, fit )
  
  Out:
  (array([ 0.4,  2.4]), inf)
  Fitted slope 1 =  0.4
  Fitted intercept 1 =  2.4
  </code></pre>
  
  <p>Things I have tried:
  -using leastsq directly: same problem
  -reinstalling scipy: no change</p>
  
  <p>I am using Anaconda on Windows 7.</p>
  
  <p>What could be the problem?</p>