Skip to content
DeepForgeby svx
All problems
MediumTime Seriests-069

VAR(1) Forecast

Problem

Forecast one step of a VAR(1) model: x_next[i] = c[i] + sum over j of A[i][j] * x_last[j], where c is the intercept vector, A is the coefficient matrix, and x_last is the current state vector.

Return the forecast vector.

Hint

Each output component is a dot product of one matrix row with the state plus its intercept.

Test cases

case 1
in: [[0.5,1],[[0.5,0.1],[0.2,0.3]],[2,3]]
expected: [1.8,2.3]
case 2
in: [[0,0],[[1,0],[0,1]],[2,3]]
expected: [2,3]
case 3
in: [[1],[[0.5]],[4]]
expected: [3]
case 4
in: [[0,0,0],[[1,2,3],[4,5,6],[7,8,9]],[1,0,-1]]
expected: [-2,-2,-2]
Starter codePython
def var1_forecast(c, A, x_last):
    # Your code here
    pass

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