All problems
CUSUM Reset Statistic
Problem
Compute the peak of a one-sided upper CUSUM with reset. For each observation update S = max(0, S + x - target - k) and track the largest S reached.
This detects persistent upward shifts relative to the target, with k the reference slack.
Hint
The reset to zero makes small deviations decay while sustained shifts accumulate.
Test cases
case 1
in: [[1,2,1,3,1],0,0.5]
expected: 5.5
case 2
in: [[0.1,0.1],0,0.5]
expected: 0
case 3
in: [[5,5,5],5,0]
expected: 0
case 4
in: [[2,4,6,8],3,1]
expected: 6
Starter codePython
def cusum_reset_statistic(series, target, k):
# Your code here
pass4 test cases · run your code against them in the editor