vendredi 15 juillet 2016

How does `interp1d` in scipy handle ties


The documentation for scipy.interpolate.interp1d is silent on what happens when there are ties in the x argument. My experimenting suggests that it returns the rightmost one when that exact x value is requested and uses the closest one when interpolating:

from scipy.interpolate import interp1d
temp = interp1d([0, 1, 1, 2], [1, 2, 3, 4])
temp(0.5)  # 1.5
temp(1)  # 3.0
temp(1.5)  # 3.5

Is this guaranteed by the design of the interpolator?


Aucun commentaire:

Enregistrer un commentaire