我是 Stack Overflow 的忠实粉丝,我相信我的问题会在这里得到解答。我正在使用 Scipy 进行线性回归。但是在一组特定的输入中,我没有得到正确的输出。(Python 2.5、SciPy 0.10.1 Windows 7 32 位)
from scipy.stats import linregress
from numpy import arange
x = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,0,1,2,0,0,2]
y = arange(1,36)
s,i,r,p,st = linregress(x,y)
这里 s 的值为 9.241573,但 Excel 报告斜率为 0.026。
我错过了什么吗?帮助。