Ling Guo Ling Guo -4 years ago 58
Python Question

Interpolation in Python

I have a x-array and a y-array (numpy, python). The y array is some function of x. The x-array is:

x = np.array([1,4,5,7,11])


The y array is:

y = np.array([4,8,9,11,14])


I want to obtain the values of y at values of x that I choose (but which are not there in the pre-existing x-array). For example, the new x-array is:

x_new = = np.array([1,2,3,4,5,6,7,8,9,10])


What is the best (and most accurate) way to do this interpolation problem in python? I am new to python and I will appreciate any help.

Answer Source

Well a good start would be to look at Numpy's interpolation method. Can get the job done for most situations.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download