Skip to content
DeepForgeby svx
All problems
HardTime Seriests-037

Holt-Winters Additive One Step

Problem

Compute the one-step-ahead forecast of the additive Holt-Winters method. Given an initial level, trend, and period seasonal offsets, iterate over the series: l = alpha * (x[t] - s[t % period]) + (1 - alpha) * (l + b); b = beta * (l - l_prev) + (1 - beta) * b; s[t % period] = gamma * (x[t] - l) + (1 - gamma) * s[t % period].

Return the forecast for the next time step, l + b + s[n % period].

Hint

Always use the old seasonal entry for the level update, then overwrite it.

Test cases

case 1
in: [[10,14,12,11,15,13],3,0.5,0.3,0.4,11,0.5,[-1,1,0]]
expected: 12.606891632812498
case 2
in: [[20,22,21,23,25,24],3,0.4,0.2,0.3,21,0.5,[0,1,-1]]
expected: 24.958005776896
case 3
in: [[5,7,6,6,8,7],3,0.6,0.4,0.5,6,0.3,[-0.5,0.5,0]]
expected: 6.9290183958527996
Starter codePython
def holt_winters_additive(series, period, alpha, beta, gamma, level0, trend0, seasonals):
    # Your code here
    pass

3 test cases · run your code against them in the editor