Commit a2b479e
committed
Merge PR #72: Add Tikhonov regularization for MVAR matrix inversion
Replaces direct matrix inverse with Tikhonov-regularized solve to prevent
LinAlgError exceptions when computing Granger causality with near-singular
matrices.
Changes:
- Replaced xp.linalg.inv() with regularized solve in MVAR computations
- Added TIKHONOV_REGULARIZATION_FACTOR constant (1e-12)
- Scale-aware regularization: λ = factor × mean(||H||²)
- Added stress test for near-singular matrices
Impact:
- Granger causality measures handle highly correlated signals gracefully
- No more LinAlgError crashes with near-singular transfer functions
- Maintains numerical accuracy for well-conditioned cases
Resolves: #72
# Conflicts:
# CHANGELOG.md
# tests/test_connectivity.pyFile tree
3 files changed
+82
-4
lines changed- spectral_connectivity
- tests
3 files changed
+82
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
86 | 97 | | |
87 | 98 | | |
88 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
74 | 78 | | |
75 | 79 | | |
76 | 80 | | |
| |||
569 | 573 | | |
570 | 574 | | |
571 | 575 | | |
572 | | - | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
573 | 583 | | |
574 | 584 | | |
575 | 585 | | |
| |||
1711 | 1721 | | |
1712 | 1722 | | |
1713 | 1723 | | |
1714 | | - | |
1715 | | - | |
1716 | | - | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
| 1730 | + | |
1717 | 1731 | | |
1718 | 1732 | | |
1719 | 1733 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
652 | 652 | | |
653 | 653 | | |
654 | 654 | | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
655 | 708 | | |
656 | 709 | | |
657 | 710 | | |
| |||
0 commit comments