def FitPolynomial(fig, x, y, n):
#solution, res = np.polynomial.polynomial.polyfit(x,y,order,full=True)
solution, C_p = np.polyfit(x, y, n, cov=True) # C_z is estimated covariance matrix
# Do the interpolation for plotting:
xrange = fig.get_xlim()
t = np.linspace(xrange[0],xrange[1],100)
# Matrix with rows 1, t, t**2, ...:
TT = np.vstack([t**(n-i) for i in range(n+1)]).T
yi = np.dot(TT, solution) # matrix multiplication calculates the polynomial values
C_yi = np.dot(TT, np.dot(C_p, TT.T)) # C_y = TT*C_z*TT.T
sig_yi = np.sqrt(np.diag(C_yi)) # Standard deviations are sqrt of diagonal
fig.plot(t,yi, 'k-')
# fig.plot(t,yi+sig_yi, 'k--')
# fig.plot(t,yi-sig_yi, 'k--')
return solution
# Take the log of the y value
plot_heating_correlations.py 文件源码
python
阅读 30
收藏 0
点赞 0
评论 0
评论列表
文章目录