compute_ma_phi#

impulso.compute_ma_phi(A, horizon)[source]#

Compute MA coefficient matrices via the structural recursion.

Numpy’s @ operator broadcasts over leading dims, so the helper handles both a single rotation and a posterior tensor of draws without branching: pass each A_j with shape (n, n) for a single-draw computation, or with shape (C, D, n, n) for a batched one.

Parameters:
  • A (list[ndarray]) – Lag coefficient matrices A_1, …, A_p in lag order. Each entry has shape (…, n, n) where the leading dims are arbitrary but shared across all entries. Must be non-empty.

  • horizon (int) – Highest MA horizon to compute. The result spans Phi_0 through Phi_horizon inclusive.

Returns:

A stacked array with the horizon axis third-to-last. For a single draw: shape (horizon + 1, n, n). For a batched posterior: shape (C, D, horizon + 1, n, n).

Raises:

ValueError – If A is empty or horizon is negative.

Return type:

ndarray