Skip to content
DeepForgeby svx
All problems
MediumTime Seriests-022

SES One-Step Forecast

Problem

Return the one-step-ahead forecast produced by simple exponential smoothing, which is the final level after processing the whole series: s[t] = alpha * x[t] + (1 - alpha) * s[t-1] with s[0] = x[0].

Return 0.0 for an empty series.

Hint

No recursion needed: just fold the series into a single running level.

Test cases

case 1
in: [[1,2,3,4],0.5]
expected: 3.125
case 2
in: [[5,5,5],0.3]
expected: 5
case 3
in: [[10],0.7]
expected: 10
case 4
in: [[2,4,6],1]
expected: 6
Starter codePython
def ses_forecast(series, alpha):
    # Your code here
    pass

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