Lesson 9 of 15

Exponential Smoothing

Exponential Smoothing

Simple Exponential Smoothing (SES) forecasts by computing a weighted average where recent observations get higher weight. The weights decay exponentially into the past.

The smoothed series s is computed as:

s[0] = xs[0]
s[t] = α · xs[t] + (1 - α) · s[t-1]

where α ∈ (0, 1) is the smoothing parameter:

  • α close to 1: reacts quickly to recent data
  • α close to 0: heavy smoothing, slow to react

Forecast

The one-step ahead forecast is simply the last smoothed value:

ŷ[t+1] = s[t]

Task

Implement:

  • exp_smooth(xs, alpha) → list of smoothed values (same length as xs)
  • exp_smooth_forecast(xs, alpha) → one-step ahead forecast
Python runtime loading...
Loading...
Click "Run" to execute your code.