series_exp_smoothing_fl()
Applies a basic exponential smoothing filter on a series.
The function series_exp_smoothing_fl() takes an expression containing a dynamic numerical array as input and applies a basic exponential smoothing filter.
Note
This function is a UDF (user-defined function). For more information, see usage.
Syntax
series_exp_smoothing_fl(y_series, [alpha])
Arguments
- y_series: Dynamic array cell of numeric values.
- alpha: An optional real value in the range [0-1], specifying the weight of the last point vs. the weight of the previous points (which is
1-alpha). Default is 0.5.
Usage
series_exp_smoothing_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_exp_smoothing_fl = (y_series:dynamic, alpha:double=0.5)
{
series_iir(y_series, pack_array(alpha), pack_array(1, alpha-1))
}
;
range x from 1 to 50 step 1
| extend y = x % 10
| summarize x = make_list(x), y = make_list(y)
| extend exp_smooth_y = series_exp_smoothing_fl(y, 0.4)
| render linechart