移動最小值(移動視窗)有誰知道如何計算移動最小值(或者就此而言,如何迭代選擇 X 數量的滯後行並對它們執行任何操作,例如計算最小值、最大值、範圍等。在這個具體示例中,我想回顧一下說出最後100 行並取得最小值,然後移至下一行並再次執行相同操作(一遍又一遍)。
實驗設計回复:最小移動(移動窗口)下面的宏並不是特別優雅,但是可以完成工作。
For ( i= 100, i <= N Rows ( dt ), i++,
dt << Select Rows (Index (i-99, i));
dt << Subset(
Selected Rows( 1 ),
Selected Columns ( 0 ),
Output Table ("out")
);
Current Data Table ( Data Table ("out"));
x = Col Minimum ( :YourDataColumn );
Close ( Data Table ( "out"), no save);
Column ( "YourMovingWindow" )[i] = x;
)子設置所選數據(我已經完成了)很慢。也許另一個用戶對如何訪問所選數據並提取所需產品有更好的主意。
我還想知道,沒有宏,列公式將如何實現結果。
乾杯,
科菲
回复:最小移動(移動窗口)這樣的事情行嗎?
Names default to here( 1 );
dt = open("$SAMPLE_DATA\Big Class.jmp");
dt << New Column("Min height 5 back",
Formula(
Min( // since we want a minumum
:height[// the column we want the minimum of
// a slice of the current row minus 5 (minimum 1 so it's still on the datatable)
// and current row
Min( Row() - 5 )::Row()
]
)
)
);