SpectralDensity.compute#
- SpectralDensity.compute()[source]#
Evaluate the exact density on the grid.
Builds the grid, the transfer function \(\Psi(\omega)\) at each point, and the Hermitian matrix \(\Psi(\omega)\Sigma_u\Psi(\omega)^*/2\pi\). The call is pure: repeated calls return equal, independent results.
- Return type:
- Returns:
The
SpectralDensityResultonn_frequenciespoints from0topi.- Raises:
NumericalError – If the lag polynomial is exactly singular at some grid frequency (an exact unit root), or the density loses Hermitian symmetry.
Example
>>> from cultivars.multivariate.reduced_form.vector_autoregression import VAR >>> rng = np.random.default_rng(0) >>> y = np.zeros((300, 2)) >>> for t in range(1, 300): ... y[t] = 0.5 * y[t - 1] + rng.standard_normal(2) >>> view = SpectralDensity(VAR(y, order=1).fit(), n_frequencies=5) >>> spec = view.compute() >>> spec.frequencies.round(3).tolist() [0.0, 0.785, 1.571, 2.356, 3.142] >>> bool(np.array_equal(spec.density, view.compute().density)) True