Difference between revisions of "Cumulate"

Line 25: Line 25:
 
! [[Cumulate]](X,I) →  
 
! [[Cumulate]](X,I) →  
 
| 8 || 10 || 10 || 15 || 12 || 19
 
| 8 || 10 || 10 || 15 || 12 || 19
 +
 
|}
 
|}
  
Line 30: Line 31:
  
 
Array Functions
 
Array Functions
 +
 +
= Optional Parameters =
 +
 +
== Cumulate(A,I,passNull:true) ==
 +
 +
When the optional «passNull» is omitted or false, [[Cumulate]] ignores [[Null]] values.  In that case they have essentially the same effect as a zero, unless they happen to be the first value in «A», in which case they are passed since no numeric values are yet obtained.
 +
 +
When «passNull» is explicitly set to true, then [[Null]] values are passed through as [[Null]] in the result.
 +
 +
:{| border="1"
 +
! B  →
 +
| [[«null»]] || [[«null»]] || 4 || 1 || [[«null»]] || [[«null»]] || 1 || 9 || 3 || 2 || [[«null»]]
 +
|-
 +
! [[Cumulate]](B,I) →
 +
| [[«null»]] || [[«null»]] || 4 || 5 || 5          || 5          || 6 || 15||18 || 20|| 20
 +
|-
 +
! [[Cumulate]](B,I,passNull:false) →
 +
| [[«null»]] || [[«null»]] || 4 || 5 || 5          || 5          || 6 || 15||18 || 20|| 20
 +
|-
 +
! [[Cumulate]](B,I,passNull:true) →
 +
| [[«null»]] || [[«null»]] || 4 || 5 || [[«null»]] || [[«null»]] || 6 || 15||18 || 20|| [[«null»]]
 +
|}
 +
  
 
= Notes =
 
= Notes =

Revision as of 22:11, 11 June 2010


Cumulate(X,I)

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)

Library

Array Functions

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

Optional Parameters

Cumulate(A,I,passNull:true)

When the optional «passNull» is omitted or false, Cumulate ignores Null values. In that case they have essentially the same effect as a zero, unless they happen to be the first value in «A», in which case they are passed since no numeric values are yet obtained.

When «passNull» is explicitly set to true, then Null values are passed through as Null in the result.

B → «null» «null» 4 1 «null» «null» 1 9 3 2 «null»
Cumulate(B,I) → «null» «null» 4 5 5 5 6 15 18 20 20
Cumulate(B,I,passNull:false) → «null» «null» 4 5 5 5 6 15 18 20 20
Cumulate(B,I,passNull:true) → «null» «null» 4 5 «null» «null» 6 15 18 20 «null»


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.