1

Is there an function for extrapolating in numpy?

I tried using the interp but of course that interpolates between the range of my values and not outside the range of values.

So for example i have my x-values between 1 and 8, inclusive, and for each x-value, i have its corresponding y-value and I want to find the y-value when my x-value is 0

import numpy as np

x = np.arange(1,8,1)
y = np.array((10,20,30,40,50,60,70))
np.interp(0,x,y)

Is there a function like the interp??

user2554925
  • 487
  • 2
  • 8

1 Answers1

0

scipy.interpolate.interp1d allows extrapolation.

import numpy as np
from scipy import interpolate

x = np.arange(1,8,1)
y = np.array((10,20,30,40,50,60,70))
interpolate.interp1d(x, y, fill_value='extrapolate')

hope this answers your question

Sandy.Arv
  • 607
  • 10
  • 34