All problems
SES Closed-Form Forecast from Initial Level
Problem
Compute the simple exponential smoothing level after passing through the whole series, starting from a supplied initial level l0. Instead of iterating, use the closed form: (1 - alpha)^n * l0 plus alpha times the geometrically weighted sum of the observations, with the most recent observation weighted most.
Return l0 itself for an empty series.
Hint
The initial level inherits the weight (1 - alpha)^n after n observations.
Test cases
case 1
in: [[1,2,3],0.5,0]
expected: 2.125
case 2
in: [[10],0.4,5]
expected: 7
case 3
in: [[],0.5,3]
expected: 3
case 4
in: [[1,2],1,0]
expected: 2
Starter codePython
def ses_closed_form(series, alpha, l0):
# Your code here
pass4 test cases · run your code against them in the editor