All problems
SES Alpha Fit Grid
Problem
Select the smoothing factor from a candidate grid that minimizes the one-step-ahead sum of squared errors. For each alpha initialize the level at x[0], then for t >= 1 accumulate (x[t] - s[t-1])^2 and update the level.
Return [best_alpha, best_sse]. If several alphas tie, keep the earliest candidate in the grid.
Hint
The forecast for x[t] is the level computed before seeing x[t].
Test cases
case 1
in: [[1,2,3,4],[0.1,0.5,0.9]]
expected: [0.9,3.4421]
case 2
in: [[5,5,5],[0.1,0.5,0.9]]
expected: [0.1,0]
case 3
in: [[1,3,5,7],[0.2,0.8]]
expected: [0.8,15.9104]
case 4
in: [[10],[0.3]]
expected: [0.3,0]
Starter codePython
def ses_alpha_fit(series, alphas):
# Your code here
pass4 test cases · run your code against them in the editor