[SciPy-Dev] curve_fit() should require initial values for parameters

Matt Newville newville at cars.uchicago.edu
Thu Jan 31 09:30:09 EST 2019


On Wed, Jan 30, 2019 at 2:26 PM Stefan van der Walt <stefanv at berkeley.edu>
wrote:

> On Wed, 30 Jan 2019 14:27:29 -0500, josef.pktd at gmail.com wrote:
> > (I'm strongly in favor of trying "defaults" first, and if that doesn't
> > work, then dig into or debug likely candidates. in loose analogy of test
> > driven development instead of up-front design.)
>
> It seems unlikely that we will reach full agreement in this thread,
> given the differing experiences and philosophies at play.  But, that's
> probably OK if we can all agree to modify the documentation to be clearer
> about the risks of the preset values for p0, how to select better
> values, and how to handle failure modes.
>
> This won't 100% address Matt's concerns, but it will go a long way to
> keeping users out of trouble, without having to make breaking changes to
> the API.
>
> What do you think?
>
>
Well, I'm not sure that agreement here should be the sole driver for what
scipy developers do.  There will be disagreements in design philosophy, and
someone needs to be willing and able to make decisions in such situations.
 I do not know who is making such decisions or reviewing changes in
`scipy.optimize`, but it appears to me that this has suffered for awhile,
leaving conceptual, interface, and organizational messes.  I thought I
would try to help by cleaning up one of the most egregious and simplest of
these.

The documentation for `curve_fit` does currrently state that `p0=None` is
converted to `np.ones(n_variables)`.  It appears that some view this as
sufficient and that these folks view some automated assignment of initial
values is useful, even while acknowledging that it cannot be correct in
general.

The argument for requiring initial values might be summarized as "initial
values are actually required".
The argument against might be summarized as "we don't want to change the
current behavior".

Anyway, I am perfectly willing to lose this argument (I do not use
`curve_fit` myself, and do not feel compelled to support its use), and the
decision is not mine to make.  I do hope someone sensible is making these
decisions.

Cheers,

--Matt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20190131/03d83fca/attachment.html>


More information about the SciPy-Dev mailing list