All problems
Multiplicative Seasonal Indices
Problem
Estimate multiplicative seasonal indices using ratio-to-centered-moving-average. Build a centered moving average with window period (averaging two adjacent moving averages when period is even), then for each season position average series[t] / trend[t] over the positions where the trend is defined.
Return the period indices, or an empty list if the series is shorter than 2*period or some position has no observations.
Hint
For an even period the centered average gives half weight to the two end points.
Test cases
case 1
in: [[10,20,12,24,11,22],2]
expected: [0.6764705882352942,1.3212176283507495]
case 2
in: [[1,2,1,2,1,2],2]
expected: [0.6666666666666666,1.3333333333333333]
case 3
in: [[5,10,15,20,25,30],2]
expected: [1,1]
case 4
in: [[1,2,3,4],3]
expected: []
Starter codePython
def multiplicative_seasonal_indices(series, period):
# Your code here
pass4 test cases · run your code against them in the editor