[SciPy-Dev] Proposal for some new fitting routines

Joseph Fox-Rabinovitz jfoxrabinovitz at gmail.com
Wed Aug 22 13:32:04 EDT 2018


On Tue, Aug 21, 2018 at 11:02 PM <josef.pktd at gmail.com> wrote:

>
>
> On Tue, Aug 21, 2018 at 10:12 PM, Joseph Fox-Rabinovitz <
> jfoxrabinovitz at gmail.com> wrote:
>
>> I had sent out an email about a PR proposing an exponential and a power
>> fit function, but I did not specify the PR number. The PR is #9158.
>>
>> Regards,
>>
>> - Joe
>>
>>
>> On Mon, Aug 20, 2018, 3:40 PM Joseph Fox-Rabinovitz <
>> jfoxrabinovitz at gmail.com> wrote:
>>
>>> I have added a function for fitting exponential and power curves. This
>>> seems to
>>> be a fairly common problem (e.g., see the list of selections from stack
>>> exchange
>>> below). The algorithm I have implemented here is objectively better than
>>> the
>>> common solution of fitting to log(y) because it requires no up-front
>>> knowledge
>>> of the intercept, or any other estimations.
>>>
>>> Assuming that this PR is acceptable, I would like to get some criticism
>>> on where
>>> I chose to put it in the directory structure. My thought was to create a
>>> separate
>>> module for such common non-iterative optimizations.
>>>
>>> I am also unsure of whether my citation of the original work is formatted
>>> properly. I would like to make sure that the author gets the credit and
>>> publicity they
>>> deserve. The paper is mentioned (by the author) in answers to [1] and
>>> [2] below.
>>>
>>> List of relevant stack exchange questions:
>>>
>>> [1]:
>>> https://stackoverflow.com/questions/3938042/fitting-exponential-decay-with-no-initial-guessing
>>> [2]:
>>> https://math.stackexchange.com/questions/1337601/fit-exponential-with-constant
>>> [3]:
>>> https://math.stackexchange.com/questions/350754/fitting-exponential-curve-to-data
>>> [4]:
>>> https://math.stackexchange.com/questions/1999069/fit-curve-exponential-maybe-to-experimental-data
>>> [5]:
>>> https://mathematica.stackexchange.com/questions/87645/exponential-fit-to-data-is-of-low-quality
>>> [6]:
>>> https://stackoverflow.com/questions/48099026/exponential-curve-fit-will-not-fit
>>> [7]:
>>> https://stackoverflow.com/questions/50683768/exponent-curve-fitting-in-python
>>> [8]:
>>> https://stackoverflow.com/questions/49565152/curve-fit-an-exponential-decay-function-in-python-using-given-data-points
>>> [9]:
>>> https://stackoverflow.com/questions/21420792/exponential-curve-fitting-in-scipy
>>>
>>> Regards,
>>>
>>> - Joe
>>>
>>
>
> The main question in my opinion is whether scipy should add functions in
> this area, this area essentially doesn't exist in scipy and is covered, for
> example, by lmfit.
>
> Except for the scipy.stats.distribution and the simple linear model, there
> are no fit or estimation methods for specific functions, AFAIK. ODR is
> related but also doesn't provide specific nonlinear functions
> scipy.optimize has the optimization algorithm but not specific nonlinear
> functions that are estimated.
>
> lmfit has built in functions for nonlinear estimation
> https://lmfit.github.io/lmfit-py/builtin_models.html
> and there some other less well known packages, AFAIR.
>
> (There was also a discussion about adding similar predefined functions to
> statsmodels, but they were never added and for those cases I usually refer
> to lmfit.)
>

lmfit definitely looks like a good choice to put the functions. On the
other hand, it offers much more advanced features than just a simple
regression.

My guess is that, unless there is a clear plan to expand in this area in
> scipy, then pointing to lmfit would be the better approach.
> Nevertheless, there could also be demand for having something simple in
> scipy. E.g. scipy.stats is a bit "eclectic" and has some overlap with
> statsmodels, or the other way around. scipy.stats has simple linear
> regression but we never added a full OLS,
>

On the other hand, the functions I propose are extremely simple, and would
do well alongside linregress if they were renamed expregress and powregress.


> multiple linear regression to scipy.stats because there would be too much
> code duplication especially if there is feature creep and users want
> similar extended results as statsmodels provides.
>
> numpy has polynomial fitting as the only fitting function, AFAIK.
>

Definitely out of scope for numpy and borderline for scipy.


>
> Josef
>
>
>
>
>
>>
>> _______________________________________________
>> SciPy-Dev mailing list
>> SciPy-Dev at python.org
>> https://mail.python.org/mailman/listinfo/scipy-dev
>>
>>
> _______________________________________________
> SciPy-Dev mailing list
> SciPy-Dev at python.org
> https://mail.python.org/mailman/listinfo/scipy-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20180822/30022b70/attachment.html>


More information about the SciPy-Dev mailing list