[SciPy-User] Sigmoid Curve Fitting

Bruce Southey bsouthey at gmail.com
Tue Sep 21 21:18:00 EDT 2010


On Tue, Sep 21, 2010 at 2:29 PM, Sturla Molden <sturla at molden.no> wrote:
>> Hi,
>>
>> Does Scipy contain the ability to fit a sigmoid curve to a set of data
>> points?
>>
>> I found some Numpy code
>> (http://pingswept.org/2009/01/24/least-squares-polynomial-fitting-in-python/)
>> for fitting curves using the least squares method, but it only seems
>> to fit parabolas to my sigmoid data.
>
> scipy.optimize.leastsq can fit any non-linear regression curve using
> Levenberg-Marquardt. You will have to supply a function that computes the
> residuals, and optionally a function that returns their Jacobian unless
> you want it estimated.
>
> Sturla
>
Ignoring that you data is the opposite,  there are a lot of 'growth
curves'  such as Richard's (growth) curve or generalized logistic
function.
http://en.wikipedia.org/wiki/Generalised_logistic_function

Also, you can fit a linear model if your model can be linearized. The
downside is that the errors are multiplicative rather than additive.
For nonlinear models, it usually helps to standardize your data.

Bruce



More information about the SciPy-User mailing list