[英]Choosing between numpy.interp vs scipy.interpolate.interp1d (with kind='linear')
I'm trying to choose between numpy.interp
vs scipy.interpolate.interp1d
(with kind='linear'
of course). 我试图在
numpy.interp
和scipy.interpolate.interp1d
之间numpy.interp
选择(当然有kind='linear'
)。 I realize they have different interfaces but that doesn't matter much to me (I can code around either interface). 我意识到他们有不同的接口,但这对我来说并不重要(我可以在任一界面编码)。 I'm wondering whether there are other differences I should be aware of.
我想知道是否还应该注意其他差异。 Thanks.
谢谢。
Numpy.interp does not handle complex-valued data or ndim>1, while scipy.interp1d does both. Numpy.interp不处理复数值数据或ndim> 1,而scipy.interp1d同时处理两者。 OTOH, numpy's interpolator is much faster (and is likely faster still in more recent numpy version).
OTOH,numpy的插值器要快得多 (并且在最近的numpy版本中可能更快)。
While numpy returns an array with discrete datapoints, 'interp1d' returns a function. 当numpy返回一个带有离散数据点的数组时,'interp1d'返回一个函数。 You can use the generated function later in your code as often as you want.
您可以根据需要随后在代码中使用生成的函数。 Furthermore, you can choose other methods than linear interpoationn
此外,您可以选择除线性插值之外的其他方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.