def ma_rep(coefs, maxn=10):
 (p, k, k) = coefs.shape
 phis = np.zeros(((maxn + 1), k, k))
 phis[0] = np.eye(k)
 for i in range(1, (maxn + 1)):
  for j in range(1, (i + 1)):
   if (j > p):
    break
   phis[i] += np.dot(phis[(i - j)], coefs[(j - 1)])
 return phis

def ma_rep ( coefs , maxn = 10 ) : ( p , k , k ) = coefs . shape phis = np . zeros ( ( ( maxn + 1 ) , k , k ) ) phis [ 0 ] = np . eye ( k ) for i in range ( 1 , ( maxn + 1 ) ) : for j in range ( 1 , ( i + 1 ) ) : if ( j > p ) : break phis [ i ] += np . dot ( phis [ ( i - j ) ] , coefs [ ( j - 1 ) ] ) return phis
ma representation of var(p) process parameters coefs : ndarray maxn : int number of ma matrices to compute notes var(p) process as .