[SciPy-user] Polyfit may be poorly conditioned
Ryan May
rmay31 at gmail.com
Mon Mar 31 11:35:40 EDT 2008
massimo sandal wrote:
> Gnata Xavier ha scritto:
>> Quoting :
>>
>> "Well think about it one second : A fit with a 12 order polynomial
>> will always have a smaller least mean square error the a fit using a
>> <12 order polynomial. Your must figure out we before using a polyfit.
>>
>> >>Well, this is reasonable but it is not what I see happening. Often
>> the algorithm takes the highest-degree polynomial, but not always."
>>
>> This simply cannot be. Polyfit is just fine. The goal of my trivial
>> example is to show that polyfit is fine.
>> My goal is only to tell to Massimo what there must be a pb somewhere
>> in its code.
>
> Pardon my utter ignorance, but imagine my data are just a straight line.
> How can a parable, or a 3rd order polynomial, fit them better than a
> straight line itself?
>
Just as it takes 2 points to define a line, it takes 3 points to define
a parabola, and n+1 points to define an nth order polynomial. Thus, you
can define a polynomial that passes through all of your data points.
This will produce an RMS error of 0. However, if you know the points
lie along a line, this is clearly not optimal and you are simply fitting
the curve to noise in the data.
Ryan
--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
More information about the SciPy-User
mailing list