【发布时间】:2023-03-27 02:07:01
【问题描述】:
我正在编写函数,这些函数将使用scipy.interpolate 函数在 python 中计算一维插值。使用文档的帮助,我为三次和三次样条插值编写了 2 个不同的函数
# calculate cubic interpolation
def linear_interpolation(x):
linear = interpolate.interp1d(support_x, support_y, 'cubic')
return linear(x)
# calculate cubic spline interpolation
def cubic_spline_interpolation(x):
tck = interpolate.splrep(support_x, support_y)
return interpolate.splev(x, tck)
我对这里的方法有点困惑。如果我使用 interpolate.interp1d(support_x, support_y, 'cubic') ,这与 cubic spline 方法不同吗?还有kind = 'quadratic'和second order spline有什么区别?
“零”、“线性”、“二次”和“三次”指的是样条曲线 零阶、一阶、二阶或三阶插值
那么为什么我必须为三次样条编写不同的函数而不是将其更改为kind='cubic'?
【问题讨论】:
标签: python scipy interpolation spline