All problems
Simple Exponential Smoothing
Problem
Apply simple exponential smoothing with smoothing factor alpha. Initialize the level to the first observation and update s[t] = alpha * x[t] + (1 - alpha) * s[t-1] for each later observation.
Return the full list of smoothed levels beginning with the initial level. An empty series gives an empty list.
Hint
Each new level is a convex blend of the newest observation and the old level.
Test cases
case 1
in: [[1,2,3,4],0.5]
expected: [1,1.5,2.25,3.125]
case 2
in: [[5,5,5],0.3]
expected: [5,5,5]
case 3
in: [[10],0.7]
expected: [10]
case 4
in: [[2,4,6],1]
expected: [2,4,6]
Starter codePython
def simple_exponential_smoothing(series, alpha):
# Your code here
pass4 test cases · run your code against them in the editor