Rolling Sum

See the following conversation, there are also some code examples in comments. In particular, this comment: