np.polyfit:用多项式拟合一系列的数据点
np.polyfit(x, y, nums)
参数:nums表示多项式次数,nums=1相当于线性拟合
np.poly1d(np.ployfit(x,y, 1)):一维多项式类
>>> x = [1,2,3,4,5,6]
>>> y = [2.5,3.51,4.45,5.52,6.47,7.51]
>>> z1 = np.polyfit(x,y,1)
>>> p1 = np.poly1d(z1)
>>> print z1
[ 1. 1.49333333]
>>> print p1
1 x + 1.493
np.polyval:用多项式对象推断下一个值
poly = np.polyfit(x, y, nums)
np.polyval(poly, x[-1] + 1)
np.roots:求多项式的根
poly = np.polyfit(x, y, nums)
np.roots(poly)