对序列应用移动平均滤波器。Applies a moving average filter on a series.

函数 series_moving_avg_fl() 接受一个包含动态数值数组的表达式作为输入,并应用简单移动平均滤波器。The function series_moving_avg_fl() takes an expression containing a dynamic numerical array as input and applies a simple moving average filter.


此函数是 UDF(用户定义的函数)This function is a UDF (user-defined function). 有关详细信息,请参阅用法For more information, see usage.


series_moving_avg_fl(y_series, n, [center])series_moving_avg_fl(y_series, n, [center])


  • y_series:数值的动态数组单元。y_series : Dynamic array cell of numeric values.
  • n:移动平均滤波器的宽度。n : The width of the moving average filter.
  • center:一个可选布尔值,该值指示移动平均是否为以下选项之一:center : An optional Boolean value that indicates whether the moving average is one of the following options:
    • 在当前点前后对称地应用于窗口,或applied symmetrically on a window before and after the current point, or
    • 从当前点向后应用于窗口。applied on a window from the current point backwards.
      默认情况下,center 为 False。By default, center is False.


series_moving_avg_fl() 是用户定义的函数。series_moving_avg_fl() is a user-defined function. 可以在查询中嵌入其代码,或将其安装在数据库中。You can either embed its code in your query, or install it in your database. 用法选项有两种:临时使用和永久使用。There are two usage options: ad hoc and persistent usage. 有关示例,请参阅下面的选项卡。See the below tabs for examples.

如果是临时使用,请使用 let 语句嵌入其代码。For ad hoc usage, embed its code using a let statement. 不需要权限。No permission is required.

let series_moving_avg_fl = (y_series:dynamic, n:int, center:bool=false)
    series_fir(y_series, repeat(1, n), true, center)
//  Moving average of 5 bins
| make-series num=count() on TimeStamp step 1h by OsVer
| extend num_ma=series_moving_avg_fl(num, 5, True)
| render timechart 

描述 5 箱的移动平均的图