Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
230 views
in Technique[技术] by (71.8m points)

python - How Can I calculate the uncertainty of a fourth degree polynomial fit?

I have an experimental data with relative uncertainties. And I would applied a fourth degree polynomial considering a specified model with logarithms. The issue im facing is how can I get an uncertainty on the fit considering the experimental data. I have no idea how can I do this. Any suggestion would be appreciated.

Thank you.

import numpy as np
import matplotlib.pyplot as plt

x = [121.78, 244.69, 344.278, 411.1165, 778.904, 867.38, 964.079, 1112.076, 1212.948, 1299.142, 1408.013] 
y = [2.98E-03, 2.18E-03, 1.64E-03, 1.79E-03, 8.09E-04, 7.54E-04, 6.80E-04, 6.11E-04, 5.83E-04, 5.49E-04, 5.01E-04] 
error_abs = [4.72E-05, 3.64E-05, 2.63E-05, 3.38E-05, 1.38E-05, 1.50E-05, 1.15E-05, 1.06E-05, 1.66E-05, 1.51E-05, 8.41E-06] # y_err

# x and y in logarithms

t1 = np.log(x)
t2 = np.log(y)

l = np.linspace(np.min(t1),np.max(t1),1000)
p,cov = np.polyfit(t1,t2,4, cov=True)
fit = np.polyval(p,l)

plt.errorbar(x, y, yerr=error_abs, lw=0.5, capsize=2, capthick=0.5, linestyle='none', marker='s',markersize=3, label='efficiency', color='orange')

plt.plot(np.exp(l),np.exp(fit), label ='Fit')

plt.show()

print(np.sqrt(np.diag(cov)))
question from:https://stackoverflow.com/questions/65944349/how-can-i-calculate-the-uncertainty-of-a-fourth-degree-polynomial-fit

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...