Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # test input
- _x = [1,1,4,8,9,5]
- _mu = 3
- # define function to handle CUSUM
- def add_by_one(input_array, my_mu):
- # initialize new array that we will return with cumulative sum values
- new_array = []
- # S0 = 0 by definition
- new_array.append(0)
- # loop through the input array values, arrays start at 0
- for index in range(len(input_array) - 1):
- current_sum = new_array[index] + input_array[index] - my_mu
- current_value = max(0, current_sum)
- new_array.append(current_value)
- return new_array
- print(add_by_one(_x, _mu))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement