spectral_connectivity.simulate.simulate_MVAR#
- simulate_MVAR(coefficients: NDArray[floating], noise_covariance: NDArray[floating] | None = None, n_time_samples: int = 100, n_trials: int = 1, n_burnin_samples: int = 100, random_state: int | Generator | None = None) NDArray[floating][source]#
Simulate multivariate autoregressive (MVAR) process.
Generates time series data following the MVAR model: X(t) = sum(A_k * X(t-k)) + E(t), where A_k are coefficient matrices and E(t) is multivariate Gaussian noise. Time
tand the lagskcount samples.- Parameters:
coefficients (NDArray[floating], shape (n_lags, n_signals, n_signals)) – MVAR coefficient matrices for each lag.
coefficients[k - 1]is A_k, the linear influence of the signalsksamples earlier: lags are sample steps, so lagkisk / sampling_frequencyseconds at whatever rate the series is analyzed with.noise_covariance (NDArray[floating], shape (n_signals, n_signals), optional) – Covariance matrix of the noise process. If None, uses identity matrix (independent unit-variance noise).
n_time_samples (int, default=100) – Number of time samples to generate (after burn-in).
n_trials (int, default=1) – Number of independent trials to simulate.
n_burnin_samples (int, default=100) – Number of initial samples to discard for equilibrium.
random_state (int, np.random.Generator, or None, optional) – Random number generator seed or instance for reproducible results.
- Returns:
time_series – Simulated time series data with specified MVAR dynamics.
- Return type:
NDArray[floating], shape (n_time_samples, n_trials, n_signals)
- Raises:
TypeError – If
coefficientsis complex.ValueError – If
coefficientsis not of shape(n_lags, n_signals, n_signals),noise_covariancenot of shape(n_signals, n_signals),n_time_samplesorn_trialsnot a positive integer, orn_burnin_samplesnot a non-negative integer.
- Warns:
UserWarning – If the coefficients are not stable: the spectral radius of their companion matrix is above 1, or within a relative 1e-12 of it (a unit root), so the process has no stationary state and the simulated series grows without bound or, for a unit root, wanders.
Examples
>>> import numpy as np >>> # Simple 2-signal VAR(1) with coupling >>> coefficients = np.array([[[0.5, 0.3], [0.2, 0.6]]]) >>> data = simulate_MVAR(coefficients, n_time_samples=1000, n_trials=5) >>> data.shape (1000, 5, 2)
Notes
The simulation uses a burn-in period to reach statistical equilibrium before collecting the requested samples.