Python Forum

Full Version: Extrapolation
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi!

I have two lists of data that I have done a linear fit on, and I would like to extrapolate this linearly but I don't really know how. I have attempted to do that but it's not working. 

from scipy.interpolate import interp1d
import matplotlib.pyplot as plt
import numpy as np

x=[1,2,3,4,5,6]
y=[2,4,6,8,10,12]

p2=np.polyfit(x,y,1)

f=interp1d(x,y,fill_value="extrapolate")
Any help is appriciated!
Hello and welcome to the forum!
Can you be more specific about what exactly is not working?
Did you get a wrong result? Did program stop because of an error?

I have not used functions from your example yet, but looking at the docs
https://docs.scipy.org/doc/scipy-0.18.1/...erp1d.html
it seems like you have to add a few more lines to get your result.