Skip to content

in first_neg_pair_start, use n = n + 1 #15

@magland

Description

@magland

def first_neg_pair_start(chain: VectorType) -> IntType:
"""
Return the index of first element of the sequence whose sum with the following
element is negative, or the length of the sequence if there is no such element.
Parameters:
chain: input sequence
Return:
index of first element whose sum with following element is negative, or
the number of elements if there is no such element
"""
N = len(chain)
n = 0
while n + 1 < N:
if chain[n] + chain[n + 1] < 0:
return n
n = n + 2
return N

I think line 74 should be n = n + 1 instead of n = n + 2 to be consistent with the description of the function. Also, with n = n + 2 I confirmed that you can get negative contributions to the area under the ACF.

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