mimin
Syntax
mimin(X, window, [minPeriods])
Please see mFunctions for the parameters and windowing logic.
Details
Return the position of the element with the smallest value in X in a sliding window. If there are multiple elements with the identical smallest value in a window, return the position of the first element from the left. Same as other aggregate functions, null values are ignored.
Returns
-
Returns a vector if X is a vector.
-
Returns a matrix if X is a matrix.
-
If X is a table, performs the calculation on each column and returns the corresponding result.
-
If X is a tuple, performs the calculation on each vector in the tuple and returns the corresponding result.
Examples
x = 1.2 2 NULL 6 -1 -1
mimin(x, 3);
// output: [,,0,0,2,1]
mimin(x, 3, 1);
// output: [0,0,0,0,2,1]
m=matrix(1 6 2 9 10 3, 9 10 2 6 6 6);
m;
| #0 | #1 |
|---|---|
| 1 | 9 |
| 6 | 10 |
| 2 | 2 |
| 9 | 6 |
| 10 | 6 |
| 3 | 6 |
mimin(m,3);
| #0 | #1 |
|---|---|
| 0 | 2 |
| 1 | 1 |
| 0 | 0 |
| 2 | 0 |
T = [2022.01.01, 2022.01.02, 2022.01.03, 2022.01.06, 2022.01.07, 2022.01.08, 2022.01.10, 2022.01.11]
X = 1..8
X1 = indexedSeries(T, X)
mimin(X1,3)
| #0 | |
|---|---|
| 2022.01.01 | 0 |
| 2022.01.02 | 0 |
| 2022.01.03 | 0 |
| 2022.01.06 | 0 |
| 2022.01.07 | 0 |
| 2022.01.08 | 0 |
| 2022.01.10 | 0 |
| 2022.01.11 | 0 |
t= 2021.01.02 2021.01.05 2021.01.06 2021.01.09 2021.01.10 2021.01.12
m=matrix(5 4 NULL -1 2 4, 3 2 8 1 0 5)
m1=m.rename!(t, `a`b).setIndexedMatrix!()
mimin(m1,3)
| a | b | |
|---|---|---|
| 2021.01.02 | 0 | 0 |
| 2021.01.05 | 0 | 0 |
| 2021.01.06 | 0 | 0 |
| 2021.01.09 | 0 | 0 |
| 2021.01.10 | 0 | 1 |
| 2021.01.12 | 0 | 0 |
