All problems
Seasonal Naive h-Step Forecast
Problem
Forecast h steps beyond the end of a series with the seasonal naive method of period m. The forecast repeats the value one full season earlier, cycling through the last m observations: the index used is n - m + ((h - 1) mod m).
Return 0.0 when m is not positive, when the series is shorter than one full season, or when h is not positive.
Hint
The forecast pattern wraps around the last complete season.
Test cases
case 1
in: [[10,20,30,40,50,60],2,1]
expected: 50
case 2
in: [[10,20,30,40,50,60],2,2]
expected: 60
case 3
in: [[10,20,30,40,50,60],2,3]
expected: 50
case 4
in: [[1,2],5,1]
expected: 0
case 5
in: [[1,2,3],3,2]
expected: 2
Starter codePython
def seasonal_naive_h_step(series, m, h):
# Your code here
pass5 test cases · run your code against them in the editor