假设我得到的数据如下:
x = [1, 2.5, 3.4, 5.8, 6]
y = [2, 4, 5.8, 4.3, 4]
我想设计一个函数,它将在之间线性插值1
and 2.5
, 2.5
to 3.4
,等等使用Python。
我尝试过浏览这个Python教程,但我仍然无法理解它。
import scipy.interpolate
y_interp = scipy.interpolate.interp1d(x, y)
print y_interp(5.0)
scipy.interpolate.interp1d通过 进行线性插值 可以自定义以处理错误情况。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)