Skip to content
DeepForgeby svx
All problems
MediumML Fundamentalsml-053

Exponential Smoothing

Problem

Apply simple exponential smoothing to a sequence: s_0 = x_0 and s_t = alpha * x_t + (1 - alpha) * s_{t-1}.

Return the smoothed values as a list; empty input returns [].

Hint

Each smoothed value blends the current observation with the previous smoothed value.

Test cases

case 1
in: [[1,2,3],0.5]
expected: [1,1.5,2.25]
case 2
in: [[10,20,30],1]
expected: [10,20,30]
case 3
in: [[5,5,5],0.3]
expected: [5,5,5]
case 4
in: [[4],0.9]
expected: [4]
Starter codePython
def exponential_smoothing(values, alpha):
    # Your code here
    pass

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