I am trying to perform linear extrapolation using the left
and right
parameters of numpy.interp.
The docs list these parameters as an "optional float or complex corresponding to fp."
My strategy is as follows, shown for left
:
f = numpy.interp(x, xp, fp, left=(x-xp[-1])*(fp[-1]-fp[-2])/(xp[-1]-xp[-2])+fp[-1], right=...)
This works just fine for single points x, but how do I format left
if I want to input a vector for x (to calculate multiple f's simultaneously)? I have tried inputting the whole vector x into the above expression but received a TypeError.