hw(<historyLength>, <tsExpression>, <smoothingFactor>, <trendFactor>) hw(<historyLength>, <seasonLength>, <samplingRate>, <tsExpression> [, <smoothingFactor>, <trendFactor>, <seasonalityFactor>])
Returns a smoothed version of the time series described by the expression, and forecasts future points using the Holt-Winters algorithm.
- For double exponential smoothing use
- If you have seasonal data, use triple exponential smoothing with
seasonLength. You can optionally specify
|historyLength||Amount of data that we use to smooth the underlying time series and to forecast. History length is expressed as time before the left side of the widow, so that
|seasonLength||Used with the triple-exponential smoothing algorithm to specify the length of one season of data. You need at least two full seasons of data to run the Holt-Winters algorithm.|
|samplingRate||Rate at which the function summarizes the points in the underlying expression, similar to the
|tsExpression||The time series on which you want to run the Holt-Winters algorithm.|
|smoothingFactor||Specifies how much old data is important relative to new data. The values range between 0 and 1, with 1 assigning the most importance to old data. See "Using Parameters to Affect hw()" below for details.|
|trendFactor||trendFactor specifies how important the trend is. The values range between 0 and 1, with 1 used for the most important trend. See "Using Parameters to Affect hw()" below for details.|
|seasonalityFactor||Optional. Used for triple-exponential smoothing to weigh the seasonality. The values range between 0 and 1, with smaller numbers weighing historical data more, and larger numbers weighing recent data more.|
hw function supports smoothing and prediction based on existing data.
- For double-exponential smoothing,
- For triple-exponential smoothing, a
seasonLengthparameter is required. The
seasonalityFactorparameters are optional. If not specified, the algorithm uses an optimization method called Nelder-Mead. Because Nelder-Mead finds local optima the same query might return two different results if the function is run twice.
Holt-Winters Triple Exponential Smoothing
Use triple exponential smoothing if your data is highly seasonal. Our implementation includes parameters to specify history length, season length, and sample rate. The optional
seasonalityFactor parameters let you fine-tune how aggressive the smoothing is. See Exponential Smoothing and other internet resources for info about the algorithm.
Holt-Winters triple exponential smoothing is a form of time series analysis that’s used primarily for periodic or seasonal data. Its main strength is catching the overall trend of data over time while maintaining the structure of the data’s seasons.
If you use the
hw() function on a time series with a set periodicity, the function can predict the next event of interest, and, for example, send an alert.
For example, assume that at certain times of the day a set of virtual machines experiences peak load. You could set up an alert for that event, or assign additional CPU and memory to them. If the peak load time changes, for example, because daylight saving time ends, the
hw() function can catch up and adjust the alert or resources.
Holt-Winters Double Exponential Smoothing
Use double exponential smoothing if you have data with only trend and no seasonality. The
smoothingFactor parameter lets you specify how much old data is important relative to new data. The
trendFactor parameter lets you specify how important the trend is.
Using Parameters to Affect hw()
You use parameters to influence how stable and how reactive the forecast is.
For double exponential smoothing,
trendFactor are required and
seasonalityFactor is not supported.
For triple exponential smoothing,
seasonalityFactor are optional.
smoothingFactor affects the weighted average of the points themselves. The weight of every point decays exponentially the further back the point is. When a new point is added to the weighted average, the weight of the new point is smoothingFactor, and the weight of the old average is
(1 – smoothingFactor). Therefore, higher values of smoothingFactor cause the algorithm to weight newer points more, making the forecast more reactive and less stable.
trendFactor affects the weighted average of the slopes between consecutive points. The algorithm uses an exponentially decaying weighted average of the slope between every two consecutive points, similar to the raw value of the points. This weighted average is calculated in the same way as the weighted average for smoothingFactor. Each time a new point is added, the slope between it and the last point is factored in with a weight of trendFactor, while the old weighted average now has weight
(1 – trendFactor). Therefore, higher values of trendFactor cause the algorithm to weight the most recent slope higher, making the forecast more reactive and less stable.
seasonalityFactor affects the weighted average of the seasonal offsets. Holt-Winters captures seasonal data by measuring the average offset of a given point into a season from the average value of that season. For example, assume history length is four weeks, season length is one week, and sampling rate is one day. Then across the four weeks of history, there is an average amount that each day differs from the average value of the week it occurs in.
Like the smoothingFactor and trendFactor, this average is a weighted average, with newer offsets having higher weights. Each time a new point is processed, it impacts the average offset from the season average by a factor of seasonalityFactor, while the old weighted average offset has a weight of
(1 – seasonalityFactor). Therefore, higher values of seasonalityFactor cause the algorithm to weight newer points more, making the forecast more reactive and less stable.
Triple Exponential Smoothing If your data for CPU usage is seasonal, use this query:
hw(4h, 1h, 1m, align(1m, ts(cpu.usage.idle)))
The function runs the Holt-Winters algorithm on the series with a season length of 1 hour and a sampling rate of 1 minute. The example doesn’t use the optional parameters to weigh smoothing, trend, and seasonality.
Double Exponential Smoothing
If your data for CPU usage is not seasonal, use this query:
hw(4h, 1m, align(1m, ts(cpu.usage.idle)))
The function runs the Holt-Winters algorithm on the series using a sampling rate of 1 minute. The example doesn’t use the optional parameters to weigh smoothing and trend.
There are requirements when using the
- The number of data points(including both the history length and the points in the window) divided by the sampling rate cannot exceed 10,000.
- For triple exponential smoothing, the sampling rate must evenly divide the season length.
See Expanding Wavefront Predictive Analytics - See the Future with Holt-Winters Algorithm for in-depth discussion of an example.