所以我有:
t = [0.0, 3.0, 5.0, 7.2, 10.0, 13.0, 15.0, 20.0, 25.0, 30.0, 35.0]
U = [12.5, 10.0, 7.6, 6.0, 4.4, 3.1, 2.5, 1.5, 1.0, 0.5, 0.3]
U_0 = 12.5
y = []
for number in U:
y.append(math.log(number/U_0, math.e))
(m, b) = np.polyfit(t, y, 1)
yp = np.polyval([m, b], t)
plt.plot(t, yp)
plt.show()
通过这样做,我得到了m=-0.1071
和b=0.0347
的线性回归拟合。
如何得到m值的偏差或误差?
我想要m = -0.1071*(1+ plus/minus error)
m is k and b is n in y=kx+n
您可以使用
scipy.stats.linregress
:标准差将存储在
std_err
。。。@Saullo卡斯特罗
很抱歉对这篇文章的评论太晚了,但是你所说的标准误差是“估计梯度的标准误差”,在你的例子中是“m”。
注意拟合误差(任何进行线性回归的人都需要)必须手动计算,以防
希望这有帮助!
相关问题 更多 >
编程相关推荐