用python实现三次样条插值

时间:2024-10-12 03:23:16

1、准备模块和数据点:import numpy as npimport pylab as plfrom scipy import interpolateimport matplotlib.pyplot as p

用python实现三次样条插值

2、运行一下,可以看到这些数据。

用python实现三次样条插值

3、画出这些数据的图形。p.plot(x, y, '^',color='red',label=u"原始数据")

用python实现三次样条插值
用python实现三次样条插值

4、用三次样条插值数据x和y。

用python实现三次样条插值
用python实现三次样条插值

5、画出这个拟合后的图像。整体代码如下图所示。

用python实现三次样条插值

6、最终效果图。

用python实现三次样条插值
© 手抄报圈