[SciPy-User] Least-squares fittings with bounds: why is scipy not up to the task?

David Baddeley david_baddeley@yahoo.com...
Thu Mar 8 20:37:48 CST 2012


You guys beat me too it - I just wanted to add that support for fixed parameters is already available in leastsq (albeit with an interface which means you have to decide which parameters are fixed when you're writing your objective function), and it's not too hard to kludge bounds by performing variable substitution (using, for example, the square of the variable if you want a one-ended constraint, or a sigmoidal function of the variable such as erf or the logistic function for an interval). This may in fact be preferable to the approach taken by mpfit in which parameters are "pegged" at the boundary as soon as they touch it.

cheers,
David 


________________________________
 From: Pauli Virtanen <pav@iki.fi>
To: scipy-user@scipy.org 
Sent: Friday, 9 March 2012 1:00 PM
Subject: Re: [SciPy-User] Least-squares fittings with bounds: why is scipy not up to the task?
 
08.03.2012 21:29, Eric Emsellem kirjoitti:
[clip]
> What I didn't find in Scipy (or numpy or..) is *an efficient 
> least-squares fitting routine which can include bounded, or fixed 
> parameters*. This seems like something many people must be needing! I am 
> right now using mpfit.py (from minpack then Craig B. Markwardt for idl 
> and Mark Rivers for python), which I did integrate in the package I am 
> developing.

mpfit is a Fortran-to-Python translation of a MINPACK routine. Scipy's
leastsq uses the original MINPACK Fortran code, so it's probably more
efficient than mpfit.py. However, the bounded parameters seems to be a
more recent addition that are not in the original.

The good news is that mpfit license seems at first sight compatible with
Scipy's. There's also an existing pull request for reimplementation of
Levenberg-Marquardt which might also work as a base for further work,
although IIRC it didn't implement bound limits. The only thing missing
is someone who needs this stuff and is not averse for a little bit of
dirty work, combining the existing pieces and making sure that the API
makes sense.

-- 
Pauli Virtanen

_______________________________________________
SciPy-User mailing list
SciPy-User@scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20120308/30003e63/attachment-0001.html 


More information about the SciPy-User mailing list