From: Greg W. <gre...@gm...> - 2006-10-13 02:30:04
|
On 10/12/06, Charles R Harris <cha...@gm...> wrote: > > And here is the location of the problem in numpy/linalg/linalg.py : > > def lstsq(a, b, rcond=1.e-10): > > The 1e-10 is a bit conservative. On the other hand, I will note that the > condition number of the dot(V^T ,V) matrix is somewhere around 1e22, which > means in general terms that you need around 22 digits of accuracy. Inverting > it only works sorta by accident in the current case. Generally, using > Vandermonde matrices and polynomial fits it a bad idea when the dynamic > range of the interval gets large and the degree gets up around 4-5 as it > leads to ill conditioned sets of equations. When you really need the best > start with chebychev polynomials or, bestest, compute a set of polynomials > orthogonal over the sample points. Anyway, I think rcond should be something > like 1e-12 or 1e-13 by default and be available as a keyword in the polyfit > function. If no one complains I will make this change, although it is just a > bandaid and things will fall apart again as soon as you call polyfit(x,y,4). > > Hey that's great. I'm glad you tracked it down. Pardon my ignorance of polyfit algorithm details. Is there a way of choosing rcond based on N that would give sensible defaults for a variety of N? Greg |