简体   繁体   中英

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). 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. OTOH, numpy's interpolator is much faster (and is likely faster still in more recent numpy version).

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM