简体   繁体   中英

interpolation with python numpy


I have an array of samples y, and corresponding x values. Some y-values may be missing and I'd like to use linear interpolation to compute them. What is the best way of doing it with python (I'm using numpy arrays). If you could provide me a sample code that would be great.

thanks

See the interpolation method in the numpy documentation that has examples:

http://docs.scipy.org/doc/numpy/reference/generated/numpy.interp.html

There are also a more extensive set of methods available through scipy:

http://docs.scipy.org/doc/scipy/reference/interpolate.html

I couldn't find anything similar to Matlab's fast interpn function, so I coded one myself:

https://github.com/fejikso/interpolator

It requires the data to be in a grid, but the coordinates don't need to be equally spaced.

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