I have a length 5 array, e.g.
array = [1,2,6,4,3]
What I want is a new array cumulatively summing a maximum set number of previous values, i.e. 3:
return_array = [1,3,9,12,13]
Using numpy's 'cumsum' function seemed like a good starting point, however it appears restricted to summing the complete range of elements, giving:
cumsum_array = np.cumsum(array)
cumsum_array = [1,3,9,13,16]
Am I missing something?