cumavg

Syntax

cumavg(X)

Arguments

X is a vector or a matrix.

Details

If X is a vector, calculate the cumulative average of X. The result is a vector of the same length as X. Null values are ignored in the calculation.

If X is a matrix, conduct the aforementioned calculation within each column of X. The result is a matrix with the same shape as X.

Examples

$ x=[2,3,NULL,4];
cumavg(x);
[2,2.5,2.5,3]

$ m=matrix(1 2 3 NULL 4, 5 6 NULL 7 8);
$ m;

#0

#1

1

5

2

6

3

7

4

8

$ cumavg(m);

#0

#1

1

5

1.5

5.5

2

5.5

2

6

2.5

6.5

Related functions: cummax, cummin, cumprod, cumPositiveStreak, cumsum