<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Hi All,</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div><div>First, I apologize in advance if this sounds un-appreciative of the efforts made in scipy and scipy.optimize.  I am a very big fan, and very appreciative of the work done here.  With lmfit we have tried to take the "rough edges" from optimization and curve-fitting with python, but we're very much in favor of building wrappers on top of the core of scipy.optimize.</div><div><br></div><div>Still, many people use `curve_fit` because it comes built-in with scipy, is well advertised, and is well-suited for simple uses.  It is clearly aimed at novices and tries to hide many of the complexities of using optimization routines for curve fitting.  I try to help people with questions about using `curve_fit` and `scipy.optimize` as well as `lmfit`.  In trying to help people using `curve_fit`, I've noticed a disturbing trend.  When a novice or even experienced user asks for help using `curve_fit` because a fit "doesn't work" there is a very good chance that they did not specify `p0` for the initial values and that the default behavior of setting all starting values to 1.0 will cause their fit to fail to converge, or really to even start.</div><div><br></div><div>This failure is understandable to an experienced user, but apparently not to the novice.  Curve-fitting problems are by nature local solvers and are always sensitive to initial values. For some problems, parameter values of 1.0 are simply inappropriate, and the numerical derivatives for some parameters near values of 1.0 will be 0.  Indeed, there is no value that is always a reasonable starting value for all parameters.  FWIW, in lmfit, we simply refuse to let a user run a curve-fitting problem without initial values.  I believe that most other curve-fitting interfaces also require initial values for all parameters.</div><div><br></div><div>Unfortunately, faced with no initial parameter values, `curve_fit` silently chooses initial values.  It doesn't try to make an informed decision, it simply chooses '1.0', which can easily be so far off as to prevent a solution from being found. When this happens, `curve_fit` gives no information to the user of what the problem is.  Indeed it allows initial values to not be set, giving the impression that they are not important.  This impression is wrong: initial values are always important. `curve_fit` is mistaken in having a default starting value.</div><div><br></div><div>I've made a Pull Request at <a href="https://github.com/scipy/scipy/pull/9701">https://github.com/scipy/scipy/pull/9701</a> to fix this misbehavior, so that `curve_fit()` requires starting values.  It was suggested there that this topic should be discussed here. I'm happy to do so.  It was suggested in the github Issue that forcing the user to give initial values was "annoying".  It was also suggested that a deprecation cycle would be required. I should say that I<span class="gmail_default" style="font-family:arial,helvetica,sans-serif"> don't actually use `curve_fit()` myself, </span>I'm just trying to help make this<span class="gmail_default" style="font-family:arial,helvetica,sans-serif"> </span>commonly used routine be completely wrong less often.</div><div><br></div><div>Cheers,</div><div><br></div><div>--Matt Newville</div></div><div><br></div></div></div>