You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tsa.stattools._sigma_est_kpss starts off with s_hat = sum(resids**2). I expect that the author didn't realize this is different from (resids**2).sum()
In [2]: resids = np.random.randn(10**5)
In [3]: sum(resids**2)
Out[3]: 99483.85416165346
In [4]: (resids**2).sum()
Out[4]: 99483.85416165383
In [5]: r2 = resids**2
In [6]: %timeit sum(r2)
100 loops, best of 3: 10.6 ms per loop
In [7]: %timeit r2.sum()
10000 loops, best of 3: 47.2 µs per loop
Activity
PERF: use np.sum(...) instead of sum(...); closes#4471