[SciPy-User] adding linear fitting routine

Daniele Nicolodi daniele at grinta.net
Wed Dec 4 06:13:59 EST 2013


On 03/12/2013 11:19, David J Pine wrote:
> I would like to get some feedback and generate some discussion about a
> least squares fitting routine I submitted last Friday  [please
> see adding linear fitting routine
> <http://comments.gmane.org/gmane.comp.python.scientific.devel/18442> (29
> Nov 2013)].  I know that everybody is very busy, but it would be helpful
> to get some feedback and, I hope, eventually to get this routine added
> to one of the basic numpy/scipy libraries.


I think that adding least squares fitting routine which handles
correctly uncertainties and computes the covariance matrix is a good
idea. I wanted to do that myself since quite a while.

However, I think that a generalization to arbitrary degree polynomials
would be much more useful.  A linfit function may be added as a
convenience wrapper.  Actually it would be nice to have something that
works on arbitrary orthogonal bases, but it may be difficult to design a
general interface for such a thing.

Regarding your pull request, I don't really think that your code can be
much faster than the general purpose lest square fitting already in
scipy or numpy, modulo some bug somewhere.  You justify that saying that
your solution is faster because it does not invert a matrix, but this is
exactly what you are doing, except that you do not write the math in a
matrix formalism.

Furthermore, I didn't have a very close look but I don't understand what
the `relsigma` parameter is supposed to do, and I would rename the
`sigmay` parameter `yerr`.

Cheers,
Daniele




More information about the SciPy-User mailing list