Linregress给出错误的结果

PKG*_*PKG 2 python statistics scipy linear-regression

我是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)
Run Code Online (Sandbox Code Playgroud)

此处s的值为9.241573,但Excel报告斜率为0.026。

我想念什么吗?救命。

pv.*_*pv. 5

您似乎以错误的方式提出了论点:

s,i,r,p,st = linregress(y,x)
Run Code Online (Sandbox Code Playgroud)

s = 0.026330532212885151。Excel和Scipy具有相反顺序的参数。