Skip to content

Fix/727 wilson factorization (lag-0 vs frequency-0) (#727) - #735

Open
emanueldellipaoli01-a11y wants to merge 3 commits into
NeuralEnsemble:masterfrom
emanueldellipaoli01-a11y:fix/727-wilson-factorization
Open

emanueldellipaoli01-a11y wants to merge 3 commits into
NeuralEnsemble:masterfrom
emanueldellipaoli01-a11y:fix/727-wilson-factorization

Conversation

@emanueldellipaoli01-a11y

@emanueldellipaoli01-a11y emanueldellipaoli01-a11y commented Dec 5, 2026 •

Copy link
Copy Markdown

Fixes #727

The Wilson factorization was incorrectly using the zero-frequency value instead of the lag-zero coefficient. The initial factor is now computed as the upper Cholesky factor of the lag-zero covariance, and both the returned covariance and transfer function are computed from the lag-zero factor.

The causal-part (bracket) operator now retains the upper triangle of the lag-zero coefficient, with a half-weighted diagonal. The Nyquist lag is handled separately for even-length transforms, and the lower triangle is no longer zeroed at frequency zero.

In pairwise_spectral_granger, the spectral density is now multiplied by the sampling frequency before factorization, ensuring that the innovation covariance is correctly scaled when fs != 1. The previously unused term_crit argument is also passed to the factorization, and the convergence check is now relative to the factor scale.

Added regression tests covering the bracket operator, the upper Cholesky convention, recovery of a known VAR factor, invariance to signal amplitude, and correct covariance scaling when fs != 1. The release notes have also been updated.

In test_pairwise_spectral_granger_against_r_grangers, the maximum deviation from the R reference for the second component drops from 0.034 to 0.010, while the mean deviation decreases from 0.017 to 0.0014. For the first component, the maximum deviation increases slightly from 0.0828 to 0.0852, so the corresponding tolerance has been raised from 0.085 to 0.09.

The factorization also converges in 6 iterations instead of 37 on this dataset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Using frequency-0 instead of lag-0 in Wilsons Factorization

1 participant