在numpy.interp和scipy.插补.interp1d之间进行选择(使用kind='linear')

时间:2022-05-04 18:15:19

I'm trying to choose between numpy.interp vs scipy.interpolate.interp1d (with kind='linear' of course). 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和scipy.插补。interp1d之间做出选择(当然是用kind='linear')。我知道它们有不同的接口,但这对我来说并不重要(我可以围绕这两个接口编写代码)。我想知道是否还有其他的不同之处。谢谢。

2 个解决方案

#1


15  

Numpy.interp does not handle complex-valued data or ndim>1, while scipy.interp1d does both. OTOH, numpy's interpolator is much faster (and is likely faster still in more recent numpy version).

interp不处理复杂值数据或ndim>1,而scipy.interp1d同时处理这两种数据。OTOH, numpy的插值器要快得多(并且在最近的numpy版本中可能更快)。

#2


5  

While numpy returns an array with discrete datapoints, 'interp1d' returns a function. You can use the generated function later in your code as often as you want. Furthermore, you can choose other methods than linear interpoationn

numpy返回一个具有离散数据池的数组,而'interp1d'返回一个函数。您可以在以后的代码中随时使用生成的函数。此外,你还可以选择其他的方法,而不是线性交叉

#1


15  

Numpy.interp does not handle complex-valued data or ndim>1, while scipy.interp1d does both. OTOH, numpy's interpolator is much faster (and is likely faster still in more recent numpy version).

interp不处理复杂值数据或ndim>1,而scipy.interp1d同时处理这两种数据。OTOH, numpy的插值器要快得多(并且在最近的numpy版本中可能更快)。

#2


5  

While numpy returns an array with discrete datapoints, 'interp1d' returns a function. You can use the generated function later in your code as often as you want. Furthermore, you can choose other methods than linear interpoationn

numpy返回一个具有离散数据池的数组,而'interp1d'返回一个函数。您可以在以后的代码中随时使用生成的函数。此外,你还可以选择其他的方法,而不是线性交叉