Skip to content
DeepForgeby svx
All problems
EasyTime Seriests-048

Exponential Smoothing State Update

Problem

Update an exponentially smoothed level given the current level, a new observation x, and smoothing factor alpha: new_level = alpha * x + (1 - alpha) * level.

Return the updated level.

Hint

alpha = 1 ignores history and jumps straight to the new observation.

Test cases

case 1
in: [10,12,0.5]
expected: 11
case 2
in: [5,5,0.3]
expected: 5
case 3
in: [0,10,1]
expected: 10
case 4
in: [10,0,0]
expected: 10
Starter codePython
def exp_smoothing_state(level, x, alpha):
    # Your code here
    pass

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