0

I am trying to extrapolate values from some endpoints as shown in the image below

extrapolated value illustration

I have tried using the scipy interp1d method as shown below

from scipy import interpolate

x = [1,2,3,4]
y = [0,1,2,0]

f = interpolate.interp1d(x,y,fill_value='extrapolate')

print(f(4.3))

output : -0.5999999999999996

Though this is correct, I also need a second extrapolated value which is the intersection of X on segment i=1.The estimated value i am expecting is ~ 3.3 as seen from the graph in the image above.But I need get this programmatically,I am hoping there should be a way of returning multiple values from interp1d(.....) or something. Any help will be much appreciated.Thanks in advance

1 Answers1

0

If you want to extrapolate based all but the last pair of values, you can just build a second interpolator, using x[:-1], y[:-1])

ev-br
  • 24,968
  • 9
  • 65
  • 78