series_dbl_exp_smoothing_fl()
Applies a double exponential smoothing filter on a series.
The function series_dbl_exp_smoothing_fl() takes an expression containing a dynamic numerical array as input and applies a double exponential smoothing filter. When there is trend in the series, this function is superior to the series_exp_smoothing_fl() function, which implements a basic exponential smoothing filter.
Note
This function is a UDF (user-defined function). For more information, see usage.
Syntax
series_dbl_exp_smoothing_fl(y_series, [alpha, beta])
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. - beta: An optional real value in the range [0-1], specifying the weight of the last slope vs. the weight of the previous slopes (which is
1-beta). Default is 0.5.
Usage
series_dbl_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_dbl_exp_smoothing_fl = (y_series:dynamic, alpha:double=0.5, beta:double=0.5)
{
series_iir(y_series, pack_array(alpha, alpha*(beta-1)), pack_array(1, alpha*(1+beta)-2, 1-alpha))
}
;
range x from 1 to 50 step 1
| extend y = x + rand()*10
| summarize x = make_list(x), y = make_list(y)
| extend dbl_exp_smooth_y = series_dbl_exp_smoothing_fl(y, 0.2, 0.4)
| render linechart