Home > database >  interp is valid for monotonically increasing sample points?
interp is valid for monotonically increasing sample points?

Time:11-17

I am reading the plot

What is the explanation for this?

CodePudding user response:

You're asking about the behaviour of interp in a regime where the documentation of interp doesn't make any claims about: The idea is that np.interp should only be used if the x-values of the sample points are monotonically increasing. Full stop. It doesn't make any claims of what happens if they are not monotonically increasing, I quote:

The x-coordinate sequence is expected to be increasing, but this is not explicitly enforced. However, if the sequence xp is non-increasing, interpolation results are meaningless.

So maybe you're lucky and the interpolation worked, maybe not. In your case I imagine it might have worked because the x-values stop being increasing well after your query point, but this is not a behaviour you should rely on.

  • Related