Professional Documents
Culture Documents
MENU
You know how to do this already. Imagine someone asked you to forecast the prices for
a certain stock, or the local temperature over the next few days. You could draw out
your prediction, and chances are it’s a pretty good one. Your brain works amazingly
well for problems like this, and our challenge is to try to get computers to do the same.
https://www.vividcortex.com/blog/exponential-smoothing-for-time-series-forecasting 1/11
6/5/2018 Exponential Smoothing for Time Series Forecasting
MENU
Image Source
If you take an introductory course on time series, you’ll learn how to forecast by tting a
model to some sample data, and then using the model to predict future values. In
practice, especially when monitoring systems, you’ll nd that this approach doesn’t
work well, if at all! Real systems rarely t mathematical models. There is an alternative.
You can do something a lot simpler with exponential smoothing.
First, let’s take a quick look at what kinds of time series we could be working with.
Suppose you measured the cpu.idle metric on a system and have observations that are
plotted below.
https://www.vividcortex.com/blog/exponential-smoothing-for-time-series-forecasting 2/11
6/5/2018 Exponential Smoothing for Time Series Forecasting
MENU
In this case, the time series isn’t particularly interesting. The values vary a reasonable
amount, but overall it’s fairly stable and most values hover around 130 or so. From a
time series analysis perspective, this is considered to be fairly stationary. If you tried to
predict the next value, your best guess would probably be around 130. It’s impossible
to be exactly right with a prediction like this, but picking a value like 130 would appear
to be the least incorrect.
Smoothing
Exponential smoothing refers to the use of an exponentially weighted moving average
(EWMA) to “smooth” a time series. If you have some time series x t , you can de ne a
new time series s t that is a smoothed version of x t .
s t = αx t + (1 − α)s t−1
Here’s a plot of a stationary time series, like the previous example, along with a couple
of smoothed versions. Notice how the smoothing amount changes with α , the
smoothing weight. The smaller the weight, the less in uence each point has on the
smoothed time series. Read our other blog post on how exponentially weighted moving
averages work for more details.
https://www.vividcortex.com/blog/exponential-smoothing-for-time-series-forecasting 3/11
6/5/2018 Exponential Smoothing for Time Series Forecasting
MENU
Suppose you had your time series x t along with a smoothed version s t . You’d like to
predict, or forecast, the next value for x t , which is x t+1 . This is simpler than you may
think! You can just use the last value you calculated for the EWMA, s t . It works out this
way because our smoothed time series is the EWMA of our original series, and because
of the way averages (and expectations) work, s t turns out to be a really good
prediction. Predicting the next value is called the one-step-ahead forecast.
This method doesn’t always work well. Remember, you made an important assumption
for this time series: it’s stationary. What happens when it isn’t?
https://www.vividcortex.com/blog/exponential-smoothing-for-time-series-forecasting 4/11
6/5/2018 Exponential Smoothing for Time Series Forecasting
MENU
https://www.vividcortex.com/blog/exponential-smoothing-for-time-series-forecasting 5/11
6/5/2018 Exponential Smoothing for Time Series Forecasting
The Keeling Curve, which plots the measured concentration of CO2 in the atmosphere,
has a positive trend and seasonality.
https://www.vividcortex.com/blog/exponential-smoothing-for-time-series-forecasting 6/11
6/5/2018 Exponential Smoothing for Time Series Forecasting
MENU
You may notice something interesting going on with the smoothed series with the
lower weight. It tends to lag behind our original data because more recent values have
lower in uence. This is especially noticeable with the seasonal time series. This is
important! Because you’re using the smoothed values to forecast, any signi cant
deviation in the smoothed values will throw off your prediction. If you notice that your
time series is not stationary, you’ll have to nd something other than a simple EWMA
to do your forecasting.
Notice how the smoothed values are much better at following the original time series
with double exponential smoothing. This means you’ll get much better forecasts.
https://www.vividcortex.com/blog/exponential-smoothing-for-time-series-forecasting 7/11
6/5/2018 Exponential Smoothing for Time Series Forecasting
MENU
To forecast with this model, you have to make a slight adjustment. Because there is
another term for the slope, you’ll have to consider that in the forecast. Suppose you’re
trying to forecast the value in m time steps in the future. The formula for the m -step-
ahead forecast, F t+m , is
F t+m = s t + mbt .
Notice how it’s essentially the formula for a line. What if your time series doesn’t have a
linear trend, but rather some sort of seasonality? For that, you’ll need yet another
EWMA.
https://www.vividcortex.com/blog/exponential-smoothing-for-time-series-forecasting 8/11
6/5/2018 Exponential Smoothing for Time Series Forecasting
MENU
Summary
Real-time anomaly detection is really a forecasting problem since you can’t know what
to expect in the present unless you use the past to forecast. Forecasting time series
data can get really sophisticated and complicated, but a lot of simple and ef cient
techniques like an EWMA can give most of the bene t with a small fraction of the cost,
effort, and complexity. More complex techniques can be good for very speci c cases,
but come at the cost of losing generality and requiring a lot more tweaking and
parameter selection, which can be surprisingly delicate to do well.
Updated 6/22/2017
https://www.vividcortex.com/blog/exponential-smoothing-for-time-series-forecasting 9/11
6/5/2018 Exponential Smoothing for Time Series Forecasting
MENU
Recent Posts
Monitor Critical Databases Con dently with the Sensitive Data Vault
Email address
Posts by Topic
Monitoring (147)
Product Features (89)
MySQL (53)
Culture (47)
News, Press and Media (45)
see all
https://www.vividcortex.com/blog/exponential-smoothing-for-time-series-forecasting 10/11
6/5/2018 Exponential Smoothing for Time Series Forecasting
MENU
300 Preston Ave, Charlottesville, Virginia 22902 United States
VividCortex - © 2018 Terms of service | Privacy policy
g k h j
https://www.vividcortex.com/blog/exponential-smoothing-for-time-series-forecasting 11/11