Python Forum
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Extrapolation
#1
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!
Reply
#2
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  prediction using linear regression (extrapolation?) in a loop karlito 0 3,181 Feb-05-2020, 10:56 AM
Last Post: karlito

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020