All problems
Smoothing Weight Decay
Problem
Compute the weight that exponential smoothing assigns to an observation j steps in the past, which is alpha * (1 - alpha)^j. The weights decay geometrically as the lag grows.
Return 0.0 for a negative lag.
Hint
A larger alpha puts more weight on recent observations.
Test cases
case 1
in: [0.5,0]
expected: 0.5
case 2
in: [0.5,2]
expected: 0.125
case 3
in: [0.3,1]
expected: 0.21
case 4
in: [0.5,-1]
expected: 0
Starter codePython
def smoothing_weight(alpha, j):
# Your code here
pass4 test cases · run your code against them in the editor