Skip to content
DeepForgeby svx
All problems
MediumTime Seriests-062

SARIMA Order Application

Problem

Apply SARIMA differencing to a series: first take d regular differences, then take D seasonal differences of lag m, where each seasonal difference is y[t] = x[t] - x[t-m] on the already differenced series.

Return the transformed series. If a seasonal difference is requested when m is not positive or the series is no longer than m, return an empty list.

Hint

Regular differencing runs first, so the series may become too short for the seasonal step.

Test cases

case 1
in: [[1,2,4,7,11,16],1,0,2]
expected: [1,2,3,4,5]
case 2
in: [[1,2,3,4,5,6,7,8],0,1,4]
expected: [4,4,4,4]
case 3
in: [[1,2,4,8,16,32],1,1,2]
expected: [3,6,12]
case 4
in: [[1,2,3],1,1,3]
expected: []
Starter codePython
def sarima_difference(series, d, D, m):
    # Your code here
    pass

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