title: why is my optimize.leastsq not working?
body: <p>I am trying to fit function to my data. I have two different axis, x-axis: height, y-axis: weight. By visual inspection, I can see, that it gives more or less the shape of square root function saturating around weight = 10. Here is what I am doing:</p>
  
  <pre><code>from scipy import optimize
  
  fitfunc = lambda p, x: np.sqrt(p[0]* x + p[1]) +p[2] # Target function
  errfunc = lambda p, x, y: fitfunc(p, x) - y
  
  sort_idx = np.argsort(height)
  height = height[sort_idx]
  weight = weight[sort_idx]
  
  p0 = [0.1, 0.2, 0.3] # initial values
  p1, success = optimize.leastsq(errfunc, p0, args=(height, weight), maxfev=10000)
  </code></pre>
  
  <p>No matter what values I set as p0, the output is always p1 = p0</p>
  
  <p>What am I doing wrong?</p>
  
  <p>Do you think it would be better to use different function if it is saturating?</p>
  
  <p>Thanks in advance!</p>