All problems
Double Exponential Smoothing
Problem
Apply Holt's double exponential smoothing and return [level, trend]. Initialize level = x[0] and trend = x[1] - x[0], then for each later x[t] compute new_level = alpha * x[t] + (1 - alpha) * (level + trend) and new_trend = beta * (new_level - level) + (1 - beta) * trend.
A single-element series returns [x[0], 0.0] and an empty series returns [0.0, 0.0].
Hint
Update the level first, then use the fresh level to update the trend.
Test cases
case 1
in: [[1,2,3,4,5],0.5,0.5]
expected: [5,1]
case 2
in: [[10,12,14,16],0.3,0.2]
expected: [16,2]
case 3
in: [[10],0.5,0.5]
expected: [10,0]
case 4
in: [[2,4],0.5,0.5]
expected: [4,2]
Starter codePython
def double_exponential_smoothing(series, alpha, beta):
# Your code here
pass4 test cases · run your code against them in the editor