Skip to main content

sim_fvarma

Function sim_fvarma 

Source
pub fn sim_fvarma(
    n: usize,
    argvals: &[f64],
    ar_ops: &[Vec<f64>],
    ma_ops: &[Vec<f64>],
    burn_in: usize,
    seed: u64,
) -> Result<FvarmaResult, FdarError>
Expand description

Simulate a functional VAR/VMA process from user-supplied operator kernels.

Generates n curves from the recurrence X_t = Σ_{k=1}^{p} A_k·X_{t-k} + ε_t + Σ_{k=1}^{q} B_k·ε_{t-k}, where each A_k (AR) and B_k (MA) is a flat column-major m×m operator kernel applied by matrix-vector product to the grid-discretized curve, and the innovations ε_t are i.i.d. standard-normal per grid point. The first burn_in curves are discarded so the kept output is approximately stationary.

§Arguments

  • n — number of output curves.
  • argvals — grid points; m = argvals.len().
  • ar_ops — AR operator kernels, each a flat m×m column-major matrix (p = ar_ops.len()).
  • ma_ops — MA operator kernels, each a flat m×m column-major matrix (q = ma_ops.len()).
  • burn_in — number of leading curves to discard (200 is a reasonable default for moderate operator norms).
  • seed — RNG seed; output is bit-identical for a fixed seed (StdRng::seed_from_u64), with no entropy fallback.

§Errors

crate::FdarError::InvalidDimension if argvals is empty or any kernel is not m×m; crate::FdarError::ComputationFailed if the recurrence diverges to NaN/Inf (a non-stationary operator).

§Stationarity

Stationarity (companion-matrix spectral radius < 1; sufficient condition ‖A_1‖_HS < 1 for FAR(1)) is the caller’s responsibility — it is not enforced, only guarded against numeric divergence.

§Divergence from freqdom

Innovations use an identity covariance (i.i.d. N(0,1) per grid point); freqdom::fts.rar accepts a user-supplied innovation covariance σ.