基于python的数学建模---高阶样条插值
作者:互联网
- 为了满足对函数光滑性的需要,我们可以使用一种有弹性的长条(称之为样条),强迫它弯曲通过样本点。
-
import numpy as np
import matplotlib.pylab as pl
from scipy import interpolate
x = np.linspace(0, 10, 11)
y = np.sin(x)
pl.figure(figsize=(12, 9))
pl.plot(x, y, 'ro')
x_new = np.linspace(0, 10, 101)
for kind in ['nearest', 'zero', 'linear', 'quadratic', 5]: #零阶,零阶,一阶,三阶,五阶
f = interpolate.interp1d(x, y, kind=kind)
y_new = f(x_new)
pl.plot(x_new, y_new, label=str(kind))
pl.xticks(fontsize=20)
pl.yticks(fontsize=20) -
#标签坐落于右下方
pl.legend(loc='lower right')
pl.show() -
标签:plot,kind,20,样条,python,---,np,new,pl 来源: https://www.cnblogs.com/kk-style/p/16523644.html