10


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

2 Answers 2

9

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

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.