python - Perform a reverse cumulative sum on a numpy array -


can recommend way reverse cumulative sum on numpy array?

where 'reverse cumulative sum' defined below (i welcome corrections on name procedure):

if

x = np.array([0,1,2,3,4]) 

then

np.cumsum(x) 

gives

array([0,1,3,6,10]) 

however, get

array([10,10,9,7,4] 

can suggest way this?

this it:

np.cumsum(x[::-1])[::-1]  

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -