series_moving_avg_fl()

Applies a moving average filter on a series.

The function series_moving_avg_fl() takes an expression containing a dynamic numerical array as input and applies a simple moving average filter.

Note

This function is a UDF (user-defined function). For more information, see usage.

Syntax

series_moving_avg_fl(y_series, n, [center])

Arguments

  • y_series: Dynamic array cell of numeric values.
  • n: The width of the moving average filter.
  • 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.
      By default, center is False.

Usage

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.

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
//
demo_make_series1
| make-series num=count() on TimeStamp step 1h by OsVer
| extend num_ma=series_moving_avg_fl(num, 5, True)
| render timechart 

Graph depicting moving average of 5 bins.