klenwell information services : Polyfit

Polyfit

A method of deriving a polynomial equation from a set of data. For more information, see curve fitting and polynomial regression.

Example

>>> import numpy
>>> x = [1,50,99]
>>> y = [2,1,0.5]
>>> a,b,c = numpy.polyfit(x,y,2)
>>> f = lambda x: a*x**2 + b*x + c
>>> f(1)
2.0
>>> f(20)
1.5528946272386506
>>> f(50)
1.0000000000000002
>>> f(90)
0.55435235318617249
>>> f(100)
0.49500208246563937
>>> f(99)
0.5