如何在polyfit权重的两个变量中包括误差

问题描述

我有两组数据,我想知道当x和y变量中都存在恒定误差时,如何找到一个polyfit(以便我可以得到最佳拟合的线性线)。

Import numpy as np
Import matplotlib as plt                 
data=np.loadtxt('Data/Resistors.csv',skiprows=2,delimiter=',')

print(data)

[[ 0.162032  2.      ]
 [ 0.254001  3.      ]
 [ 0.249856  4.      ]
 [ 0.420033  5.      ]
[ 0.364007  6.      ]]


#Define
I=data[0:,0]
diff_V=data[:,1]
#Error of each variable
err_I=0.03 #Constant error
err_diff_V=0.5 #Constant error

#polyfitting
fit_diff_V,cov_diff_V=np.polyfit(I,diff_V,1,w=1/(#what should I enter here?),cov=True)

我应该在weight参数中输入什么,以便我的最佳拟合线可以考虑到I和diff_V造成的错误

(我的讲师演示了加权问题,只有一个错误是针对自变量的)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)