polynomial interpolate

来源:互联网 发布:淘宝助理中通大头笔 编辑:程序博客网 时间:2024/06/11 22:07

polynomial interpolate

Wiki Polynomial interpolation\

scipy

solve this system of linear equations:

p(x)=anxn+an1xn1++a2x2+a1x+a0


We have to solve this system for ak to construct the interpolant p(x). The matrix on the left is commonly referred to as a Vandermonde matrix.

Lagrange polynomial

WIki

Lagrange polynomials

example

x f(x) 1 1 2 8 3 27


L(1.5)=3

code

from scipy.interpolate import lagrangeL = lagrange([1,2,3],[1,8,27])print(L)#poly1d([  6., -11.,   6.])L(1.5)#3.0#checkimport numpy as npvandermonate = np.vander([1,2,3])A = L.coeffsy = np.dot(vandermonate,A)print(y)

Vandermonde:

numpy.vander

polyvander

deal with null numbers using interpolate

pandas

filled = df.interpolate(method='spline', order=4)#viewdf.plot()filled.plot()
  • method: {‘linear’, ‘time’, ‘index’, ‘values’, ‘nearest’, ‘zero’,‘slinear’, ‘quadratic’, ‘cubic’, ‘barycentric’, ‘krogh’, ‘polynomial’, ‘spline’ ‘piecewise_polynomial’, ‘pchip’}

    see: scipy

0 0