cummax

Syntax

cummax(X)

Arguments

X is a vector/matrix.

Details

If X is a vector, cumulatively calculate the maximum values in X and returns a vector of the same length as X. It can be used to calculate maximum drawdown, for example.

If X is a matrix, perform the calculation mentioned above along each row and returns a matrix of the same dimension as X.

Examples

$ x = [7,4,5,8,9]
$ cummax(x);
[7,7,7,8,9]

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

#0

#1

6

3

5

9

7

4

8

2

1

10

$ cummax(m);

#0

#1

6

3

6

9

7

9

8

9

8

10

Related functions: cummin, cumsum, cumprod