All problems
Croston vs SES Comparison
Problem
Compare Croston and simple exponential smoothing on the same intermittent series with smoothing factor alpha. Return [croston_forecast, ses_forecast], where the SES level is initialized with the first observation and updated over all points, including zeros.
If the series has no nonzero demand the Croston forecast is 0.0.
Hint
Croston ignores zero periods when updating demand size; SES does not.
Test cases
case 1
in: [[0,0,4,0,0,6,0,2],0.5]
expected: [1.4,1.8125]
case 2
in: [[0,0,0],0.3]
expected: [0,0]
case 3
in: [[5],0.5]
expected: [5,5]
case 4
in: [[1,0,3,0],0.5]
expected: [1.3333333333333333,0.875]
Starter codePython
def croston_vs_ses(series, alpha):
# Your code here
pass4 test cases · run your code against them in the editor