Skip to content

sigma_est_kpss sum(foo) vs foo.sum() #4471

Closed

Description

@jbrockmendel

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions