我想要一個類似於Col Moving Average()的內置函數,用於計算aa列的移動(滾動)分位數。 您可以將其稱為Col Moving Quantile()和/或Col Moving Median()。
我編寫了一個用戶函數(附加),該函數對於小型表已經足夠好了,但是它使用的效率很低。 我絕對確定,有很多更有效的方法來實現此功能,而無需在每個滾動步驟中重新進行蠻力計算。 這些方法超出了我的編碼能力。
</CODE></P><PRE><CODE class=" language-jsl">Add Custom Functions(
New Custom Function(
"x",
"Col Moving Quantile",
Function( {col, p, before, after, dt = Current Data Table()},
{coldata = Column( dt, col ) << Get As Matrix, from = Max( Row() - before, 1 ), to, to = Min( Row() + after, N Rows( dt ) )},
Quantile( p, coldata[Index( from, to )] )
)
)
// === Documentation ===
<<FORMULA category=""> )" ) //
<<PARAMETER></PARAMETER></FORMULA>