Algorithm Search⌘K

Algorithmcore

Holt-Winters method

Also called triple exponential smoothing, Holt's linear trend method.

Forecasts by exponentially smoothed updates of a level, a trend and a seasonal component. Holt's method has level and trend only.

Time
Θ(n + h) worst · best
Space
Θ(m) extra
Where
h = the forecast horizon; m = the seasonal period; n = the length of the series
Properties
deterministicexactonlineiterative
Origin
Charles C. Holt, Peter R. Winters, 1957

The Holt-Winters method forecasts a series by keeping three running estimates: a level, a trend (the change per step), and a seasonal effect for each position in the period. After each observation it moves each estimate a fixed fraction toward what the new value suggests, exactly as an exponential moving average does. The forecast hh steps ahead is the level plus hh times the trend, plus the seasonal effect for that position. Without the seasonal part this is Holt's linear method, which gives exactly the same forecasts as an ARIMA(0, 2, 2) model. The method needs O(1)O(1) work per observation, handles additive or multiplicative seasons, and has stayed a strong baseline for sales and demand forecasting since the 1960s.

In plain words

Think of forecasting sales that grow and rise every December. You keep three numbers: where sales are now, how fast they grow, and how much each month is usually above or below normal. When a new month comes in, you compare it with what you expected. You then nudge each number part of the way toward the new evidence: a little if you trust the past, a lot if you think things change fast. To forecast, you start from where sales are now, add the growth for each month ahead, and add that month's usual bump. Three dials, between 0 and 1, set how fast each number reacts.

The problem

Given y1,…,yny_1, \dots, y_n, a seasonal period mm (or none), and smoothing constants α,β,γ∈[0,1]\alpha, \beta, \gamma \in [0, 1], compute the one-step forecasts y^t∣t−1\hat y_{t|t-1} for t=1..nt = 1..n and the forecasts y^n+h∣n\hat y_{n+h|n}, h=1,2,…h = 1, 2, \dots, of the additive model

y^t∣t−1=ℓt−1+bt−1+st−m\hat y_{t|t-1} = \ell_{t-1} + b_{t-1} + s_{t-m}

with the level ℓt\ell_t, the trend btb_t and the seasonal states sts_t updated by the recursions of the algorithm. In the multiplicative model the season multiplies, y^t∣t−1=(ℓt−1+bt−1)st−m\hat y_{t|t-1} = (\ell_{t-1} + b_{t-1})s_{t-m}. The constants are chosen by minimizing the sum of squared one-step errors ∑tet2\sum_te_t^2, et=yt−y^t∣t−1e_t = y_t - \hat y_{t|t-1}, which is the Gaussian maximum likelihood estimate in the matching state space model.

The algorithm

  1. HOLT-WINTERS(y₁..y_n, m, α, β, γ, h; start ℓ₀, b₀, s_{1−m..0})
  2. for t ← 1 to n
  3. 1ŷ_t ← ℓ_{t−1} + b_{t−1} + s_{t−m}
  4. 2e_t ← y_t − ŷ_t
  5. 3ℓ_t ← α (y_t − s_{t−m}) + (1 − α)(ℓ_{t−1} + b_{t−1})
  6. 4b_t ← β (ℓ_t − ℓ_{t−1}) + (1 − β) b_{t−1}
  7. 5s_t ← γ (y_t − ℓ_{t−1} − b_{t−1}) + (1 − γ) s_{t−m}
  8. 6ŷ_{n+k} ← ℓ_n + k b_n + s_{n+k−m(⌊(k−1)/m⌋+1)}, k = 1..h
  9. 7return (ŷ, e, ℓ_n, b_n, s, ŷ_{n+1..n+h}, Σ e_t²)

Holt's linear method drops line L5 and the ss terms. Simple exponential smoothing also drops line L4 and sets b=0b = 0. For multiplicative seasons, line L1 becomes (ℓt−1+bt−1)st−m(\ell_{t-1} + b_{t-1})s_{t-m}, line L3 uses yt/st−my_t/s_{t-m}, and line L5 uses yt/(ℓt−1+bt−1)y_t/(\ell_{t-1} + b_{t-1}). The classical start sets ℓ0\ell_0 to the mean of the first season, b0b_0 to the difference of the first two season means divided by mm, and si−ms_{i-m} to yi−ℓ0y_i - \ell_0 for i=1..mi = 1..m. For Holt's method it sets ℓ0=y1\ell_0 = y_1 and b0=y2−y1b_0 = y_2 - y_1. Modern software estimates the start values together with the constants.

Line L3 can be written ℓt=ℓt−1+bt−1+αet\ell_t = \ell_{t-1} + b_{t-1} + \alpha e_t, line L4 as bt=bt−1+αβetb_t = b_{t-1} + \alpha\beta e_t, and line L5 as st=st−m+γets_t = s_{t-m} + \gamma e_t. This error correction form shows each state moving by a fixed share of the forecast error. Winters (1960) wrote the seasonal update with yt−ℓty_t - \ell_t in place of yt−ℓt−1−bt−1y_t - \ell_{t-1} - b_{t-1}. That is the same method with γ=γ∗(1−α)\gamma = \gamma^*(1 - \alpha).

Example

Holt's method by hand. Take y=(10,12,15,14,18,21)y = (10, 12, 15, 14, 18, 21), α=β=1/2\alpha = \beta = 1/2, ℓ0=10\ell_0 = 10 and b0=2b_0 = 2.

tt yty_t y^t\hat y_t (L1) ete_t (L2) ℓt\ell_t (L3) btb_t (L4)
1 10 12 −2-2 11 1.5
2 12 12.5 −0.5-0.5 12.25 1.375
3 15 13.625 1.375 14.3125 1.71875
4 14 16.03125 −2.03125-2.03125 15.015625 1.2109375
5 18 16.2265625 1.7734375 17.11328125 1.654296875
6 21 18.767578125 2.232421875 19.8837890625 2.21240234375

All values are exact dyadic fractions: ℓ6=20361/1024\ell_6 = 20361/1024 and b6=4531/2048b_6 = 4531/2048. Line L6 gives y^7=22.096\hat y_7 = 22.096, y^8=24.309\hat y_8 = 24.309 and y^9=26.521\hat y_9 = 26.521, a straight line with slope b6b_6. With θ1=α(1+β)−2=−5/4\theta_1 = \alpha(1 + \beta) - 2 = -5/4 and θ2=1−α=1/2\theta_2 = 1 - \alpha = 1/2, the ARIMA(0, 2, 2) recursion y^t+1=2yt−yt−1+θ1et+θ2et−1\hat y_{t+1} = 2y_t - y_{t-1} + \theta_1e_t + \theta_2e_{t-1} started from y^2=12.5\hat y_2 = 12.5 and e1=−2e_1 = -2, reproduces every later forecast in the table, and the three forecasts beyond it, exactly.

With a season. Take quarterly data y=(12,8,14,10,16,11,17,14,19,14,21,17)y = (12, 8, 14, 10, 16, 11, 17, 14, 19, 14, 21, 17), m=4m = 4, additive seasons, α=1/2\alpha = 1/2, β=γ=1/4\beta = \gamma = 1/4. The classical start is ℓ0=11\ell_0 = 11 (mean of the first year), b0=(14.5−11)/4=7/8b_0 = (14.5 - 11)/4 = 7/8, and s=(1,−3,3,−1)s = (1, -3, 3, -1). Then y^1=11+0.875+1=12.875\hat y_1 = 11 + 0.875 + 1 = 12.875, e1=−0.875e_1 = -0.875, ℓ1=0.5⋅11+0.5⋅11.875=11.4375\ell_1 = 0.5 \cdot 11 + 0.5 \cdot 11.875 = 11.4375, b1=0.25⋅0.4375+0.75⋅0.875=0.765625b_1 = 0.25 \cdot 0.4375 + 0.75 \cdot 0.875 = 0.765625, and s1=0.25⋅0.125+0.75⋅1=0.78125s_1 = 0.25 \cdot 0.125 + 0.75 \cdot 1 = 0.78125. After all 12 points, ℓ12=18.734\ell_{12} = 18.734, b12=0.727b_{12} = 0.727, s=(1.978,−3.347,2.583,−1.509)s = (1.978, -3.347, 2.583, -1.509), and the forecasts for the next year are 21.44,16.84,23.50,20.1321.44, 16.84, 23.50, 20.13.

Simulated monthly data. With seed 2026, simulate 144 months from the additive model with α=0.3\alpha = 0.3, αβ=0.03\alpha\beta = 0.03, γ=0.2\gamma = 0.2, noise standard deviation 2 and a sine-shaped season of amplitude 10. Fit on the first 120 months by a grid search for the smallest sum of squared errors: it picks α=0.2\alpha = 0.2, β=0.16\beta = 0.16, γ=0.3\gamma = 0.3. On the last 24 months, the root mean square error is 2.11 for Holt-Winters, 8.55 for the seasonal naive forecast (the value one year earlier), and 12.0 for Holt's method without seasons. These are measured on one sample.

Correctness

The correctness page proves the following. The recursions are equivalent to the error correction form. Winters' form is the component form with γ=γ∗(1−α)\gamma = \gamma^*(1 - \alpha). Holt's linear method and ARIMA(0, 2, 2) with θ1=α(1+β)−2\theta_1 = \alpha(1 + \beta) - 2 and θ2=1−α\theta_2 = 1 - \alpha give identical one-step and hh-step forecasts from the same start. The MA polynomial is invertible exactly when 0<α<20 < \alpha < 2 and 0<αβ<4−2α0 < \alpha\beta < 4 - 2\alpha. A series that is a line plus a fixed season, or a line times a fixed season, is forecast with zero error for any constants once the start is right. The method is exact arithmetic on its inputs, so the tests check it in rationals. The optimality of the forecasts for the ETS state space models (Hyndman et al. 2002) is cited, not proved.

Proof: Holt-Winters has an error correction form, Winters' seasonal update is a reparametrization, Holt's linear method gives the ARIMA(0, 2, 2) forecasts, and noise-free trend-plus-season series are forecast exactlyfull

We prove the error correction form of the recursions (Lemma 1), the equivalence of Winters' seasonal update with the component form (Lemma 2), the equivalence of Holt's linear method with ARIMA(0, 2, 2) for one-step and hh-step forecasts (Theorem 3), the invertibility region (Corollary 4), and exactness on noise-free series (Lemma 5). We do not prove that the forecasts are optimal (minimum mean squared error) for the ETS state space models of Hyndman, Koehler, Snyder and Grose (2002), the equivalence of the additive seasonal method with a seasonal ARIMA model, or any property of the constants chosen by least squares. Indices: y^t\hat y_t is the forecast of yty_t made at t−1t - 1 (line L1), and et=yt−y^te_t = y_t - \hat y_t (line L2).

Lemma 1 (error correction form). Lines L3 to L5 are equivalent to

ℓt=ℓt−1+bt−1+αet,bt=bt−1+αβet,st=st−m+γet\ell_t = \ell_{t-1} + b_{t-1} + \alpha e_t, \qquad b_t = b_{t-1} + \alpha\beta e_t, \qquad s_t = s_{t-m} + \gamma e_t

in the additive seasonal method, and to the first two with et=yt−ℓt−1−bt−1e_t = y_t - \ell_{t-1} - b_{t-1} in Holt's method.

Proof. Line L3: α(yt−st−m)+(1−α)(ℓt−1+bt−1)=ℓt−1+bt−1+α(yt−st−m−ℓt−1−bt−1)=ℓt−1+bt−1+αet\alpha(y_t - s_{t-m}) + (1 - \alpha)(\ell_{t-1} + b_{t-1}) = \ell_{t-1} + b_{t-1} + \alpha(y_t - s_{t-m} - \ell_{t-1} - b_{t-1}) = \ell_{t-1} + b_{t-1} + \alpha e_t. Line L4: β(ℓt−ℓt−1)+(1−β)bt−1=bt−1+β(ℓt−ℓt−1−bt−1)=bt−1+αβet\beta(\ell_t - \ell_{t-1}) + (1 - \beta)b_{t-1} = b_{t-1} + \beta(\ell_t - \ell_{t-1} - b_{t-1}) = b_{t-1} + \alpha\beta e_t, by the first identity. Line L5: γ(yt−ℓt−1−bt−1)+(1−γ)st−m=st−m+γ(yt−ℓt−1−bt−1−st−m)=st−m+γet\gamma(y_t - \ell_{t-1} - b_{t-1}) + (1 - \gamma)s_{t-m} = s_{t-m} + \gamma(y_t - \ell_{t-1} - b_{t-1} - s_{t-m}) = s_{t-m} + \gamma e_t. Holt's method is the case s≡0s \equiv 0. □\square

Lemma 2 (Winters' form). Winters (1960) updates the season by st=γ∗(yt−ℓt)+(1−γ∗)st−ms_t = \gamma^*(y_t - \ell_t) + (1 - \gamma^*)s_{t-m}, with ℓt\ell_t from line L3. This is line L5 with γ=γ∗(1−α)\gamma = \gamma^*(1 - \alpha).

Proof. From line L3, yt−ℓt=yt−αyt+αst−m−(1−α)(ℓt−1+bt−1)=(1−α)(yt−ℓt−1−bt−1)+αst−my_t - \ell_t = y_t - \alpha y_t + \alpha s_{t-m} - (1 - \alpha)(\ell_{t-1} + b_{t-1}) = (1 - \alpha)(y_t - \ell_{t-1} - b_{t-1}) + \alpha s_{t-m}. Substituting, st=γ∗(1−α)(yt−ℓt−1−bt−1)+(γ∗α+1−γ∗)st−m=γ(yt−ℓt−1−bt−1)+(1−γ)st−ms_t = \gamma^*(1 - \alpha)(y_t - \ell_{t-1} - b_{t-1}) + (\gamma^*\alpha + 1 - \gamma^*)s_{t-m} = \gamma(y_t - \ell_{t-1} - b_{t-1}) + (1 - \gamma)s_{t-m}, since γ∗α+1−γ∗=1−γ∗(1−α)=1−γ\gamma^*\alpha + 1 - \gamma^* = 1 - \gamma^*(1 - \alpha) = 1 - \gamma. □\square

Theorem 3 (Holt's method is ARIMA(0, 2, 2)). In Holt's method put ft=ℓt+btf_t = \ell_t + b_t, the forecast of yt+1y_{t+1} made at tt, and θ1=α(1+β)−2\theta_1 = \alpha(1 + \beta) - 2, θ2=1−α\theta_2 = 1 - \alpha. Then for every t≥3t \ge 3,

∇2yt=et+θ1et−1+θ2et−2,ft=2yt−yt−1+θ1et+θ2et−1.(1)\nabla^2y_t = e_t + \theta_1e_{t-1} + \theta_2e_{t-2}, \qquad f_t = 2y_t - y_{t-1} + \theta_1e_t + \theta_2e_{t-1}. \tag{1}

The second equation is the one-step forecast of ARIMA(0, 2, 2) with moving average polynomial θ(z)=1+θ1z+θ2z2\theta(z) = 1 + \theta_1z + \theta_2z^2, computed from its innovations. So, started from the same f2f_2 and e1e_1, the two methods produce the same one-step forecasts and the same errors for all later tt. The hh-step forecasts agree as well: Holt's ℓn+hbn\ell_n + hb_n equals the ARIMA forecast for every h≥1h \ge 1.

Proof. By Lemma 1, ft−ft−1=(ℓt−ℓt−1)+(bt−bt−1)=bt−1+αet+αβetf_t - f_{t-1} = (\ell_t - \ell_{t-1}) + (b_t - b_{t-1}) = b_{t-1} + \alpha e_t + \alpha\beta e_t. Taking one more difference and using bt−1−bt−2=αβet−1b_{t-1} - b_{t-2} = \alpha\beta e_{t-1},

∇2ft=αβet−1+α(1+β)(et−et−1)=α(1+β)et−αet−1.\nabla^2f_t = \alpha\beta e_{t-1} + \alpha(1 + \beta)(e_t - e_{t-1}) = \alpha(1 + \beta)e_t - \alpha e_{t-1}.

Since yt=ft−1+ety_t = f_{t-1} + e_t for all tt, ∇2yt=∇2ft−1+∇2et=α(1+β)et−1−αet−2+et−2et−1+et−2\nabla^2y_t = \nabla^2f_{t-1} + \nabla^2e_t = \alpha(1 + \beta)e_{t-1} - \alpha e_{t-2} + e_t - 2e_{t-1} + e_{t-2}, which is et+(α(1+β)−2)et−1+(1−α)et−2e_t + (\alpha(1 + \beta) - 2)e_{t-1} + (1 - \alpha)e_{t-2}. That is the first equation of (1). Apply it at t+1t + 1 with yt+1=ft+et+1y_{t+1} = f_t + e_{t+1}: ft+et+1−2yt+yt−1=et+1+θ1et+θ2et−1f_t + e_{t+1} - 2y_t + y_{t-1} = e_{t+1} + \theta_1e_t + \theta_2e_{t-1}, which gives the second equation. The ARIMA(0, 2, 2) model ∇2yt=εt+θ1εt−1+θ2εt−2\nabla^2y_t = \varepsilon_t + \theta_1\varepsilon_{t-1} + \theta_2\varepsilon_{t-2} has the one-step forecast 2yt−yt−1+θ1εt+θ2εt−12y_t - y_{t-1} + \theta_1\varepsilon_t + \theta_2\varepsilon_{t-1}, with εt=yt−(its forecast)\varepsilon_t = y_t - (\text{its forecast}). Both recursions map (ft−1,et−1,yt,yt−1)(f_{t-1}, e_{t-1}, y_t, y_{t-1}) to ftf_t by the same formula, so by induction on tt they agree from a common start.

For hh steps, the ARIMA forecasts set future innovations to 0: y^n+1=fn\hat y_{n+1} = f_n, y^n+2=2fn−yn+θ2en\hat y_{n+2} = 2f_n - y_n + \theta_2e_n, and y^n+k=2y^n+k−1−y^n+k−2\hat y_{n+k} = 2\hat y_{n+k-1} - \hat y_{n+k-2} for k≥3k \ge 3. Holt gives ℓn+kbn\ell_n + kb_n. For k=1k = 1 both are fnf_n. For k=2k = 2, Holt gives fn+bnf_n + b_n, and 2fn−yn+(1−α)en−(fn+bn)=ℓn−yn+(1−α)en2f_n - y_n + (1 - \alpha)e_n - (f_n + b_n) = \ell_n - y_n + (1 - \alpha)e_n. By Lemma 1, ℓn=fn−1+αen=yn−en+αen\ell_n = f_{n-1} + \alpha e_n = y_n - e_n + \alpha e_n, so this difference is 0. For k≥3k \ge 3 both sequences satisfy xk=2xk−1−xk−2x_k = 2x_{k-1} - x_{k-2}, which determines a sequence from its first two terms, so they agree for all kk. □\square

Corollary 4 (invertibility). The polynomial θ(z)=1+(α(1+β)−2)z+(1−α)z2\theta(z) = 1 + (\alpha(1 + \beta) - 2)z + (1 - \alpha)z^2 has both roots outside the unit circle if and only if 0<α<20 < \alpha < 2 and 0<αβ<4−2α0 < \alpha\beta < 4 - 2\alpha.

Proof. For 1+θ1z+θ2z21 + \theta_1z + \theta_2z^2 the roots lie outside the unit circle if and only if ∣θ2∣<1|\theta_2| < 1, θ1+θ2>−1\theta_1 + \theta_2 > -1 and θ2−θ1>−1\theta_2 - \theta_1 > -1 (the stationarity triangle of an AR(2) polynomial 1−ϕ1z−ϕ2z21 - \phi_1z - \phi_2z^2 with ϕi=−θi\phi_i = -\theta_i). Here ∣1−α∣<1|1 - \alpha| < 1 is 0<α<20 < \alpha < 2; θ1+θ2=αβ−1>−1\theta_1 + \theta_2 = \alpha\beta - 1 > -1 is αβ>0\alpha\beta > 0; and θ2−θ1=3−2α−αβ>−1\theta_2 - \theta_1 = 3 - 2\alpha - \alpha\beta > -1 is αβ<4−2α\alpha\beta < 4 - 2\alpha. □\square

Inside this region the errors ete_t are a convergent linear filter of the data, and the effect of the start values on the forecasts dies out geometrically. All constants in (0,1)(0, 1) lie inside it.

Lemma 5 (exactness on noise-free series). Let yt=a+ct+σty_t = a + ct + \sigma_t with σt+m=σt\sigma_{t+m} = \sigma_t, and start the additive method at ℓ0=a\ell_0 = a, b0=cb_0 = c, si−m=σis_{i-m} = \sigma_i for i=1..mi = 1..m. Then et=0e_t = 0 for all tt and any α,β,γ\alpha, \beta, \gamma, and y^n+k=yn+k\hat y_{n+k} = y_{n+k} for all k≥1k \ge 1. The same holds for yt=(a+ct)σty_t = (a + ct)\sigma_t with the multiplicative method and σt≠0\sigma_t \ne 0, a+ct≠0a + ct \ne 0.

Proof. By induction on tt, with the claim ℓt−1=a+c(t−1)\ell_{t-1} = a + c(t - 1), bt−1=cb_{t-1} = c, and the seasonal state for position tt equal to σt\sigma_t. It holds for t=1t = 1 by the start. Then y^t=a+ct+σt=yt\hat y_t = a + ct + \sigma_t = y_t, so et=0e_t = 0, and by Lemma 1 ℓt=ℓt−1+bt−1=a+ct\ell_t = \ell_{t-1} + b_{t-1} = a + ct, bt=cb_t = c and st=st−m=σt=σt+ms_t = s_{t-m} = \sigma_t = \sigma_{t+m}. The forecasts of line L6 are a+c(n+k)+σn+k=yn+ka + c(n + k) + \sigma_{n+k} = y_{n+k}. In the multiplicative case, line L1 gives (a+ct)σt=yt(a + ct)\sigma_t = y_t; line L3 gives α(a+ct)+(1−α)(a+ct)=a+ct\alpha(a + ct) + (1 - \alpha)(a + ct) = a + ct; line L4 gives cc; and line L5 gives γyt/(a+ct)+(1−γ)σt=σt\gamma y_t/(a + ct) + (1 - \gamma)\sigma_t = \sigma_t. □\square

Exact arithmetic. Every line uses only additions, subtractions, multiplications and, in the multiplicative case, divisions of the inputs. With rational data and constants the outputs are rational, and the implementation computes them exactly when given Fractions. The tests check the worked examples, Theorem 3 and Lemmas 2 and 5 in rationals.

Termination. The loop runs nn times and line L6 runs hh times, each with O(1)O(1) work, so the method stops after Θ(n+h)\Theta(n + h) operations. The grid search for the constants evaluates the method a fixed number of times.

Complexity

On a real RAM, each observation costs O(1)O(1) arithmetic operations, so a pass over nn points takes Θ(n)\Theta(n) time and line L6 takes Θ(h)\Theta(h). The state is the level, the trend and mm seasonal values, Θ(m)\Theta(m) space; the method is online. Choosing the constants by minimizing the squared errors takes one pass per evaluation: a grid of GG values per constant costs Θ(G3n)\Theta(G^3n), and a quasi-Newton or Nelder-Mead search typically needs a few hundred passes.

Numerical stability. The recursions are convex combinations when the constants are in [0,1][0, 1], so rounding errors do not grow: each state is a weighted average of past values with weights that sum to 1. The multiplicative form divides by st−ms_{t-m} and by ℓt−1+bt−1\ell_{t-1} + b_{t-1}. It breaks down when the series is near 0 or changes sign, and it should be used only for positive data.

Properties

  • Exact for its model class. Lines plus fixed seasons are reproduced with zero error, for any constants.
  • Equivalent to ARIMA models. Simple exponential smoothing is the optimal forecast of ARIMA(0, 1, 1) (Muth 1960). Holt's method gives the forecasts of ARIMA(0, 2, 2). The additive Holt-Winters method gives the forecasts of a seasonal ARIMA model with differences ∇∇m\nabla\nabla_m and a moving average part of order m+1m + 1 with restricted coefficients.
  • State space form. Each method is the steady forecast recursion of an innovations state space model (ETS), which gives a likelihood, AIC model choice and prediction intervals.
  • Online. Each new observation updates the states in constant time.
  • Weights decay geometrically. The level is a weighted average of past values with weights α(1−α)j\alpha(1 - \alpha)^j in simple exponential smoothing.
  • Not robust. One outlier shifts the level, the trend and the season, and the trend carries the error into all later forecasts.

Variants and improvements

  • Damped trend. Gardner and McKenzie (1985) multiply the trend by ϕ<1\phi < 1 at each step, so long-range forecasts level off. The damped trend is often more accurate than Holt's linear trend for horizons beyond a few steps.
  • Multiplicative seasons. The seasonal effect scales with the level, which suits series whose swings grow with their size.
  • ETS framework. Hyndman, Koehler, Snyder and Grose (2002) give fifteen combinations of error, trend and season types, with likelihoods for estimation and selection by AIC.
  • Several seasonal periods. Taylor's double seasonal method and the TBATS models handle, for example, daily and weekly cycles in hourly data.
  • Robust versions. Replace the squared error loss by a robust loss, or clean outliers first, for example with STL.
  • Brown's double exponential smoothing. One constant aa for level and trend. It is Holt's method with α=a(2−a)\alpha = a(2 - a) and β=a/(2−a)\beta = a/(2 - a), so both are ARIMA(0, 2, 2) with the double root θ(z)=(1−(1−a)z)2\theta(z) = (1 - (1 - a)z)^2.

When to use it

Use Holt-Winters for short- to medium-term forecasts of a series with a stable trend and season, especially when there are many series and each needs a cheap, automatic forecast, such as inventory or demand planning. It is a strong baseline: compare any new method with it. Use the damped trend for longer horizons. If the series has several seasonal periods, outliers, or effects of covariates, use STL followed by a forecast of the seasonally adjusted series, a seasonal ARIMA model, or a regression with ARIMA errors.

Pitfalls

  • Bad start values. The classical start uses only the first two seasons. With small constants, a poor start biases forecasts for a long time. Estimate the start with the constants.
  • Additive versus multiplicative. If the seasonal swing grows with the level, additive seasons underfit large values; use multiplicative seasons or take logs.
  • Linear trend extrapolation. Holt's trend continues forever. Long-horizon forecasts from a recent upswing can be far off; damp the trend.
  • Overfitting the constants. Minimizing in-sample squared errors with a large γ\gamma can chase noise. Check the forecasts on a holdout sample.
  • Conflicting parameter conventions. Different books use β\beta for the trend update in ℓt−ℓt−1\ell_t - \ell_{t-1} (as here) or for αβ\alpha\beta in the error form, and γ\gamma or γ∗\gamma^* for the season. Check the convention before copying constants between programs.
  • Prediction intervals. The method gives point forecasts only. Intervals need the state space model; naive intervals from in-sample errors are too narrow for long horizons.

Implementations

Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.

holt_winters_method.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/holt-winters-method/. The authors are listed in prov/56FTG8.jsonl.
"""Holt's linear method and the Holt-Winters seasonal method.

Component form (Hyndman and Athanasopoulos), additive seasonality, period m:

    forecast  yhat_t = l_(t-1) + b_(t-1) + s_(t-m)
    level     l_t = alpha (y_t - s_(t-m)) + (1 - alpha)(l_(t-1) + b_(t-1))
    trend     b_t = beta (l_t - l_(t-1)) + (1 - beta) b_(t-1)
    season    s_t = gamma (y_t - l_(t-1) - b_(t-1)) + (1 - gamma) s_(t-m)

Multiplicative seasonality divides by the seasonal index instead of
subtracting it. With seasonal=None it is Holt's linear method. All the
arithmetic is generic, so Fractions in give Fractions out.
"""

import math


def initial_states(y, m=None, seasonal=None):
    """Classical start values.

    Holt: l_0 = y_1, b_0 = y_2 - y_1. Seasonal: l_0 is the mean of the first
    season, b_0 is the difference of the first two season means divided by m,
    and s is the first season minus (or divided by) l_0."""
    if seasonal is None:
        if len(y) < 2:
            raise ValueError("need at least 2 observations")
        return y[0], y[1] - y[0], []
    if m is None or m < 2 or len(y) < 2 * m:
        raise ValueError("need a period m >= 2 and at least two full seasons")
    first = sum(y[:m]) / m
    second = sum(y[m:2 * m]) / m
    level, trend = first, (second - first) / m
    if seasonal == "add":
        season = [y[i] - level for i in range(m)]
    elif seasonal == "mul":
        season = [y[i] / level for i in range(m)]
    else:
        raise ValueError("seasonal must be None, 'add' or 'mul'")
    return level, trend, season


def holt_winters(y, alpha, beta, gamma=0, m=None, seasonal=None, h=0, init=None):
    """Run the smoothing recursions and forecast h steps ahead.

    Returns a dict with the one-step forecasts and errors for t = 1..n, the
    final level, trend and seasonal states, the h forecasts and the sum of
    squared one-step errors. init = (l_0, b_0, s_(1-m..0)) overrides the
    classical start; the default classical start uses the data from t = 1."""
    if seasonal is not None and seasonal not in ("add", "mul"):
        raise ValueError("seasonal must be None, 'add' or 'mul'")
    level, trend, season = init if init is not None else initial_states(y, m, seasonal)
    season = list(season)
    period = len(season)
    fitted, errors = [], []
    for t, obs in enumerate(y):
        s = season[t % period] if period else None
        if seasonal == "add":
            yhat = level + trend + s  # @line L1
        elif seasonal == "mul":
            yhat = (level + trend) * s
        else:
            yhat = level + trend
        e = obs - yhat  # @line L2
        if seasonal == "add":
            new_level = alpha * (obs - s) + (1 - alpha) * (level + trend)  # @line L3
            season[t % period] = gamma * (obs - level - trend) + (1 - gamma) * s  # @line L5
        elif seasonal == "mul":
            new_level = alpha * (obs / s) + (1 - alpha) * (level + trend)
            season[t % period] = gamma * (obs / (level + trend)) + (1 - gamma) * s
        else:
            new_level = alpha * obs + (1 - alpha) * (level + trend)
        trend = beta * (new_level - level) + (1 - beta) * trend  # @line L4
        level = new_level
        fitted.append(yhat)
        errors.append(e)
    n = len(y)
    forecasts = []
    for k in range(1, h + 1):
        base = level + k * trend
        if seasonal == "add":
            base = base + season[(n + k - 1) % period]  # @line L6
        elif seasonal == "mul":
            base = base * season[(n + k - 1) % period]
        forecasts.append(base)
    sse = sum(e * e for e in errors)
    return {"fitted": fitted, "errors": errors, "level": level, "trend": trend,  # @line L7
            "season": season, "forecasts": forecasts, "sse": sse}


def fit(y, m=None, seasonal=None, grid=None):
    """Choose alpha, beta (and gamma) by the smallest sum of squared one-step
    errors over a grid, then refine by a finer grid around the best point.
    Returns (alpha, beta, gamma, sse)."""
    grid = grid or [i / 10 for i in range(1, 10)]
    gammas = grid if seasonal else [0.0]
    best = (math.inf, None)

    def search(alphas, betas, gs):
        nonlocal best
        for a in alphas:
            for b in betas:
                for g in gs:
                    if seasonal and not 0 <= g <= 1 - a:
                        continue
                    sse = holt_winters([float(v) for v in y], a, b, g, m, seasonal)["sse"]
                    if sse < best[0]:
                        best = (sse, (a, b, g))

    search(grid, grid, gammas)
    a0, b0, g0 = best[1]
    near = lambda c: [x for x in (c - 0.04, c - 0.02, c, c + 0.02, c + 0.04) if 0.0 < x < 1.0]
    search(near(a0), near(b0), near(g0) if seasonal else [0.0])
    a, b, g = best[1]
    return a, b, g, best[0]


def arima022_forecasts(y, theta1, theta2, f0, e0):
    """One-step forecasts of ARIMA(0, 2, 2) from its innovations recursion.

    f_t = 2 y_t - y_(t-1) + theta1 e_t + theta2 e_(t-1), started from the
    forecast f0 of y_2 made at t = 1 and the innovation e0 at t = 1."""
    fc, prev_e, e_t = [f0], e0, None
    for t in range(1, len(y) - 1):
        e_t = y[t] - fc[-1]
        fc.append(2 * y[t] - y[t - 1] + theta1 * e_t + theta2 * prev_e)
        prev_e = e_t
    return fc
test_holt_winters_method.py 137 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/holt-winters-method/. The authors are listed in prov/56FTG8.jsonl.

import math
import random
from fractions import Fraction

import pytest

from holt_winters_method import arima022_forecasts, fit, holt_winters, initial_states

HOLT_Y = [Fraction(v) for v in (10, 12, 15, 14, 18, 21)]
SEASONAL_Y = [Fraction(v) for v in (12, 8, 14, 10, 16, 11, 17, 14, 19, 14, 21, 17)]


def test_holt_worked_example() -> None:
    r = holt_winters(HOLT_Y, Fraction(1, 2), Fraction(1, 2), h=3)
    assert r["fitted"] == [12, Fraction(25, 2), Fraction(109, 8), Fraction(513, 32), Fraction(2077, 128),
                           Fraction(9609, 512)]
    assert r["level"] == Fraction(20361, 1024) and r["trend"] == Fraction(4531, 2048)
    assert r["forecasts"] == [Fraction(45253, 2048), Fraction(6223, 256), Fraction(54315, 2048)]
    assert r["sse"] == Fraction(4822241, 262144)


def test_seasonal_worked_example() -> None:
    assert initial_states(SEASONAL_Y, 4, "add") == (11, Fraction(7, 8), [1, -3, 3, -1])
    r = holt_winters(SEASONAL_Y, Fraction(1, 2), Fraction(1, 4), Fraction(1, 4), 4, "add", h=4)
    assert r["fitted"][0] == Fraction(103, 8) and r["errors"][0] == Fraction(-7, 8)
    assert r["fitted"][1] == Fraction(589, 64)
    want = [21.439065563, 16.842204589, 23.499558342, 20.134910795]
    assert all(abs(float(p) - q) < 1e-9 for p, q in zip(r["forecasts"], want))


@pytest.mark.parametrize("alpha,beta", [(Fraction(1, 2), Fraction(1, 2)), (Fraction(3, 10), Fraction(1, 5)),
                                        (Fraction(9, 10), Fraction(1, 10)), (Fraction(1), Fraction(0))])
def test_holt_equals_arima_0_2_2(alpha, beta) -> None:
    # One-step forecasts agree exactly with theta1 = alpha (1 + beta) - 2 and
    # theta2 = 1 - alpha, from the same start, and so do all h-step forecasts.
    rng = random.Random(5)
    y = [Fraction(rng.randint(-20, 20)) for _ in range(15)]
    r = holt_winters(y, alpha, beta, h=6)
    th1, th2 = alpha * (1 + beta) - 2, 1 - alpha
    fc = arima022_forecasts(y, th1, th2, r["fitted"][1], r["errors"][0])
    assert fc == r["fitted"][1:]
    # h-step ARIMA(0,2,2) forecasts: yhat(n+1), then 2 yhat(n+1) - y_n + theta2 e_n, then a straight line.
    n = len(y)
    e = r["errors"]
    f1 = 2 * y[-1] - y[-2] + th1 * e[-1] + th2 * e[-2]
    arima = [f1, 2 * f1 - y[-1] + th2 * e[-1]]
    while len(arima) < 6:
        arima.append(2 * arima[-1] - arima[-2])
    assert arima == r["forecasts"]
    # and the errors satisfy the MA(2) recursion for the second differences
    for t in range(2, n):
        assert y[t] - 2 * y[t - 1] + y[t - 2] == e[t] + th1 * e[t - 1] + th2 * e[t - 2]


def test_winters_form_equals_component_form() -> None:
    # Winters (1960) smooths the season with y_t - l_t; that equals the component
    # form with gamma = gamma_star (1 - alpha).
    a, b, gs = Fraction(2, 5), Fraction(1, 3), Fraction(1, 2)
    level, trend, season = initial_states(SEASONAL_Y, 4, "add")
    season = list(season)
    fitted = []
    for t, obs in enumerate(SEASONAL_Y):
        s = season[t % 4]
        fitted.append(level + trend + s)
        new_level = a * (obs - s) + (1 - a) * (level + trend)
        season[t % 4] = gs * (obs - new_level) + (1 - gs) * s
        trend = b * (new_level - level) + (1 - b) * trend
        level = new_level
    r = holt_winters(SEASONAL_Y, a, b, gs * (1 - a), 4, "add")
    assert r["fitted"] == fitted


@pytest.mark.parametrize("seasonal", ["add", "mul"])
def test_exact_on_noise_free_data(seasonal) -> None:
    # A line plus a fixed season (or a line times a fixed season) is forecast
    # with zero error for any smoothing constants, from the classical start.
    m = 4
    s_add = [3, -1, -4, 2]
    s_mul = [Fraction(5, 4), Fraction(3, 4), Fraction(1, 2), Fraction(3, 2)]
    y = []
    for t in range(20):
        line = Fraction(50) + Fraction(3, 2) * (t + 1)
        y.append(line + s_add[t % m] if seasonal == "add" else line * s_mul[t % m])
    # the true start: level and trend at t = 0, the season for t = 1..m
    init = (Fraction(50), Fraction(3, 2), s_add if seasonal == "add" else s_mul)
    r = holt_winters(y, Fraction(1, 3), Fraction(1, 5), Fraction(1, 7), m, seasonal, h=5, init=init)
    assert all(e == 0 for e in r["errors"])
    for k in range(1, 6):
        t = 20 + k
        line = Fraction(50) + Fraction(3, 2) * t
        want = line + s_add[(t - 1) % m] if seasonal == "add" else line * s_mul[(t - 1) % m]
        assert r["forecasts"][k - 1] == want


def test_simple_exponential_smoothing_special_case() -> None:
    # beta = 0 and b_0 = 0 give simple exponential smoothing, an exponential moving average.
    y = [Fraction(v) for v in (3, 7, 4, 8, 6)]
    a = Fraction(1, 3)
    r = holt_winters(y, a, Fraction(0), init=(y[0], Fraction(0), []))
    ema = y[0]
    for t, obs in enumerate(y):
        assert r["fitted"][t] == ema
        ema = a * obs + (1 - a) * ema
    assert r["level"] == ema


def test_fit_recovers_seasonal_structure() -> None:
    # Simulate ETS(A,A,A) with alpha = 0.3, beta* = 0.1, gamma = 0.2, noise SD 2;
    # the fitted Holt-Winters forecasts beat the seasonal naive forecast.
    rng = random.Random(2026)
    m, n = 12, 144
    level, trend = 100.0, 0.5
    season = [10 * math.sin(2 * math.pi * i / m) for i in range(m)]
    y = []
    for t in range(n):
        e = rng.gauss(0, 2)
        y.append(level + trend + season[t % m] + e)
        level, trend = level + trend + 0.3 * e, trend + 0.03 * e
        season[t % m] += 0.2 * e
    a, b, g, sse = fit(y[:120], m, "add")
    assert 0 < a < 1 and 0 < b < 1 and 0 <= g <= 1 - a
    fc = holt_winters(y[:120], a, b, g, m, "add", h=24)["forecasts"]
    rmse = math.sqrt(sum((p - q) ** 2 for p, q in zip(fc, y[120:])) / 24)
    snaive = math.sqrt(sum((y[120 + k - 12 * (1 + k // 12)] - y[120 + k]) ** 2 for k in range(24)) / 24)
    assert rmse < 3.0 < snaive


def test_bad_input() -> None:
    with pytest.raises(ValueError):
        holt_winters([1, 2, 3, 4, 5, 6, 7, 8], 0.5, 0.5, 0.5, 4, "xyz")
    with pytest.raises(ValueError):
        initial_states([1, 2, 3], 4, "add")
    with pytest.raises(ValueError):
        initial_states([1])

History

Robert Brown used exponential smoothing for inventory control in the U.S. Navy in the 1950s. Charles Holt, at the Carnegie Institute of Technology, wrote the level and trend method and sketched seasonal factors in a 1957 report to the Office of Naval Research; the report circulated for decades and was published in 2004. Peter Winters, also at Carnegie, tested the seasonal method on sales data in 1960. Muth (1960) showed that simple exponential smoothing is optimal for a random walk observed with noise, and Box and Jenkins linked the methods to ARIMA models. Gardner (1985, 2006) surveyed the field, and Hyndman, Koehler, Snyder and Grose (2002) put the methods on a state space footing with likelihoods.

References

  1. Charles C. Holt, Forecasting seasonals and trends by exponentially weighted moving averages, International Journal of Forecasting 20(1) (2004), pages 5 to 10, a reprint of the 1957 ONR memorandum, the level and trend recursions and the seasonal factors
  2. Peter R. Winters, Forecasting sales by exponentially weighted moving averages, Management Science 6(3) (1960), pages 324 to 342, the multiplicative seasonal model and its tests on sales series
  3. Everette S. Gardner Jr., Exponential smoothing, the state of the art, Journal of Forecasting 4(1) (1985), pages 1 to 28, the survey of the methods and their equivalences with ARIMA models
  4. Everette S. Gardner Jr., Exponential smoothing, the state of the art, part II, International Journal of Forecasting 22(4) (2006), pages 637 to 666, the damped trend, the state space models and the parameter choices
  5. Rob J. Hyndman, Anne B. Koehler, Ralph D. Snyder and Simone Grose, A state space framework for automatic forecasting using exponential smoothing methods, International Journal of Forecasting 18(3) (2002), pages 439 to 454, the innovations state space models (ETS) behind each method, with likelihoods and prediction intervals
  6. John F. Muth, Optimal properties of exponentially weighted forecasts, Journal of the American Statistical Association 55(290) (1960), pages 299 to 306, simple exponential smoothing as the optimal forecast of a random walk plus noise

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH1 sketch
  • a full proof of time.best
  • a full proof of time.worst
  • a full proof of space.extra
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a scene preset for the example