mLowRange

Syntax

mLowRange(X, window, [minPeriods])

Please see mFunctions for the parameters and windowing logic.

Details

For each element Xi in a sliding window of X, count the continuous nearest neighbors to its left that are larger than Xi. NULLs are treated as the minimum values.

If X is a matrix, conduct the aforementioned calculation within each column of X.

Examples

x = [NULL, 3.1, NULL, 3.0, 2.9, 2.8, 3.1, NULL, 3.2]
mLowRange(x, window=3) 
// output: [,,1,0,1,2,0,2,0]

mLowRange(x, window=3, minPeriods=1) 
// output: [,0,1,0,1,2,0,2,0]

mLowRange(x, window=3, minPeriods=2) 
// output: [,,,0,1,2,0,2,0]

date = [0, 1, 2, 3, 7, 8, 9, 10, 11] + 2020.01.01
X = indexedSeries(date, x)
mLowRange(X, 3d)

#0

2020.01.01
2020.01.02 0
2020.01.03 1
2020.01.04 0
2020.01.08 0
2020.01.09 1
2020.01.10 0
2020.01.11 2
2020.01.12 0
m = matrix(1 2 3 NULL, 1 2 NULL 3, 1 3 NULL NULL, 1 2 3 4)
mLowRange(m, 2)

#0

#1

#2

#3

0 0 0 0
0 1 1 0
1 0 0