[SciPy-user] nonlinear fit with non uniform error?

Christian K ckkart@hoc....
Wed Jun 20 08:33:45 CDT 2007

massimo sandal wrote:
> Hi,
> We have a set of data that we fit to a nonlinear function using
> scipy.optimize.leastsq that, AFAIK, uses the Levenberg-Marquardt method.
> Talking with a collegue of another lab, he pointed me that the dataset
> we fit usually has intrinsically more noise in the first part of the
> data than the latter. So he fitted by taking into account the non
> uniform error -that is, instead of using plain chi-square, giving more
> weight to the distance from points with less intrinsic error. He told me
> that on Origin there is a function that does it. Is there something
> similar on scipy?

Have a look at scipy.odr. This module does orthogonal distance regression (or
just normal least squares if you prefer). Interesting for you is the fact that
you can pass an array containing the weights of the data. Even better, odr gives
you an error estimation of the fit.
Note that in scipy versions <= 0.5.2 odr resides in scipy.sandbox.odr, however
there is a bug which prevents importing itm which is fixed in svn.
You might want to have a look at peak-o-mat (http://lorentz.sf.net), too. It's a
general data fitting application which makes use of scipy.odr.


More information about the SciPy-user mailing list