CUSUM Function

CUSUM (matrix) ;

The CUSUM function computes cumulative sums. The argument to this function is a numeric matrix or literal.

The CUSUM function returns a matrix of the same dimension as the argument matrix. The result contains the cumulative sums obtained by adding the nonmissing elements of the argument in row-major order.

For example, the following statements compute cumulative sums:

a = cusum({1 2 4 5});
b = cusum({5 6, 3 4});
print a, b;

Figure 23.81: Cumulative Sums

a
1 3 7 12

b
5 11
14 18