What is the technique used by the numpy interp() function?
So using the following points
import numpy as np
x = [4.5]
xp = [4, 5, 4, 3]
yp = [2, 4, 6, 5]
result = np.interp(x, xp, yp)
print(result) #result = 5.0
When I find the interpolation of x the value is 4.5
But if my points are these 3 xp = [4, 5, 4] e yp = [2, 4, 6] the value will be 6
import numpy as np
x = [4.5]
xp = [4, 5, 4]
yp = [2, 4, 6]
result = np.interp(x, xp, yp)
print(result) #result = 6.0
Your
xparray is not strictly increasing. In fact, you even have a repeated value with different correspondingfpvalues! In this case, the behavior is undefined.From the
numpy.interpdocumentation: