Plotting confidence and prediction intervals with repeated entries

坚强是说给别人听的谎言 提交于 2019-11-29 02:34:10

You need to order your predict values based on temperature. I think*

So to get nice curvy lines you will have to use numpy.polynomial.polynomial.polyfit This will return a list of coefficients. You will have to split the x and y data into 2 lists so it fits in the function.

You can then plot this function with:

def strPolynomialFromArray(coeffs):
    return("".join([str(k)+"*x**"+str(n)+"+" for n,k in enumerate(coeffs)])[0:-1])

from numpy import *
from matplotlib.pyplot import *
x = linespace(-15,45,300) # your smooth line will be made of 300 smooth pieces
y = exec(strPolynomialFromArray(numpy.polynomial.polynomial.polyfit(xs,ys,degree)))
plt.plot(x , y)

You can look more into plotting smooth lines here just remember all lines are linear splines, becasue continuous curvature is irrational.

I believe that the polynomial fitting is done with least squares fitting (process described here)

Good Luck!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!