Difference between revisions of "Cumulate"

Line 34: Line 34:
  
 
= See Also =
 
= See Also =
 +
 +
* [[Uncumulate]]
 +
* [[Sum]]
 +
* [[CumProduct]]
 +
* [[media:Recumulate example.ana|Recumulate example.ana]]

Revision as of 07:41, 7 August 2008


Returns an array with each element being the sum of all of the elements of X along dimension I up to, and including, the corresponding element of X.

Declaration

Cumulate(X:Array[I] ; I : Index)

Examples

I → 1 2 3 4 5 6
X → 8 2 0 5 -3 7
Cumulate(X,I) → 8 10 10 15 12 19

Library

Array Functions

Notes

Recumulate

A useful variation is the Recumulate function, which resets the total to zero at selected points. This usage is:

Recumulate(x,b,I)

where b is an array of booleans indexed by I, having 1 at each point where the cumulation is to be reset to zero. Recumulate is implemented as a User-Defined Function in the example Recumulate example.ana. A clever usage of this function computes the number of time steps that the system has been in the same state (see the example).

See Also

Comments


You are not allowed to post comments.