用Python进行样条插值

用Python进行样条插值,第1张

用Python进行样条插值

从scipy.interpolate.interp1d上的scipy文档中:

scipy.interpolate.interp1d(x,y,kind =’linear’,axis = -1,copy =
True,bounds_error = True,fill_value = np.nan)

x:类似array_。一维数组,单调递增实数值。

问题是x值不是单调增加的。实际上,它们正在单调减少。让我知道这是否有效,以及它是否仍在您要寻找的计算中。:

import numpy as npimport scipy as spfrom scipy.interpolate import interp1dx1 = sorted([1., 0.88, 0.67, 0.50, 0.35, 0.27, 0.18, 0.11, 0.08, 0.04, 0.04, 0.02])y1 = [0., 13.99, 27.99, 41.98, 55.98, 69.97, 83.97, 97.97, 111.96, 125.96, 139.95, 153.95]new_length = 25new_x = np.linspace(x.min(), x.max(), new_length)new_y = sp.interpolate.interp1d(x, y, kind='cubic')(new_x)


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5650144.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-16
下一篇2022-12-16

发表评论

登录后才能评论

评论列表(0条)

    保存