[SciPy-Dev] curve_fit() should require initial values for parameters
Nils Geib
nilsc.becker at gmail.com
Thu Jan 24 05:03:40 EST 2019
Just one small remark: in my experience many users utilize curve_fit to fit
linear models (models that are linear in the fit parameters, e.g. f(x) = a
* exp(-x) + b * exp(-x^2)). In this case the linear least squares problem
can be solved uniquely without providing initial values for a and b. Even
though curve_fit employs a general nonlinear least squares solver it should
be able to find the global minimum for virtually all starting values
(although I have not comprehensively tested it). On the other hand when the
model is truly nonlinear the initial values of curve_fit fail with very
high probability.
One may argue that using curve_fit for such cases is not the right choice.
However, scipy does not provide a convenient interface such as curve_fit
for linear models (as far as I know). And users who are not aware that a
nonlinear least squares solver requires good initial values may also not be
aware of the difference between linear and nonlinear models. (When I teach
I regularly encounter the misconception that models that are nonlinear in
the independent variable, e.g., x, require a nonlinear solver).
Long story short: when deprecating the initial choice for p0 it may be
worthwile to also consider providing a convenient interface for lsq_linear
that is similar to curve_fit and does not require initial values.
Cheers
Nils
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20190124/301a2343/attachment-0001.html>
More information about the SciPy-Dev
mailing list