Skip to content
DeepForgeby svx
All problems
MediumTime Seriests-344

MA(1) Forecast from Last Residual

Problem

Forecast the next h values of an MA(1) process with mean mu, coefficient theta, and last observed residual e_last. The one-step forecast is mu + theta * e_last; every later forecast is the process mean mu because the memory of an MA(1) lasts only one step.

Return an empty list when h is not positive.

Hint

Only the one-step forecast depends on the most recent residual.

Test cases

case 1
in: [0,0.5,2,3]
expected: [1,0,0]
case 2
in: [5,-0.4,1.5,2]
expected: [4.4,5]
case 3
in: [1,0,9,1]
expected: [1]
case 4
in: [0,0.5,2,0]
expected: []
Starter codePython
def ma1_forecast(mu, theta, e_last, h):
    # Your code here
    pass

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