Skip to content

Fix SCCA_PMD's bisection to be scale-invariant - #230

Merged
jameschapman19 merged 1 commit into
mainfrom
fix/scca-pmd-scale-invariant-tau
Aug 16, 2026
Merged

Fix SCCA_PMD's bisection to be scale-invariant#230
jameschapman19 merged 1 commit into
mainfrom
fix/scca-pmd-scale-invariant-tau

Conversation

@jameschapman19

Copy link
Copy Markdown
Owner

Summary

  • _bisect_threshold compared the unnormalised power-iteration update's raw L1 norm directly against l1_bound (tau * sqrt(p)), a bound that is only meaningful for a unit-L2-norm vector (||w||_1 <= sqrt(p) for ||w||_2 = 1 is the Cauchy-Schwarz bound tau in (0, 1] relies on).
  • Since the raw update's magnitude depends on the data's scale, not on tau, this made the effective sparsity constraint depend on the data's scale: whenever the raw update's L1 norm exceeded l1_bound (the common case for reasonably-sized n), tau bound far more aggressively than intended -- up to and including tau=1 ("no sparsity constraint") still collapsing to near-total sparsity.
  • Fixed by bisecting on the thresholded vector's L1/L2 ratio instead of its raw L1 norm, which is invariant to the overall scale of the input.

Test plan

  • Added test_scca_pmd_invariant_to_input_scale: fits on the same data scaled by 37x and checks the recovered direction is unchanged (up to sign).
  • Added test_scca_pmd_tau_controls_sparsity_monotonically: checks nnz is non-decreasing in tau, and that tau=1 (nominally unconstrained) recovers the fully dense solution.
  • Full suite: 511 passed, 7 skipped.

Generated by Claude Code

_bisect_threshold compared the unnormalised power-iteration update's raw
L1 norm directly against l1_bound (tau*sqrt(p)), a bound that is only
meaningful for a unit-L2-norm vector. Since the raw update's magnitude
depends on the data's scale (not on tau), this made the effective
sparsity constraint depend on the data's scale: in the common case where
the raw update's L1 norm exceeds l1_bound, tau bound far more
aggressively than intended, up to and including tau=1 (nominally "no
sparsity constraint") still collapsing to near-total sparsity.

Fixed by bisecting on the L1/L2 ratio of the thresholded vector instead,
which is invariant to the input's overall scale. Added regression tests
for scale-invariance and tau-monotonicity.
@jameschapman19
jameschapman19 merged commit b2e8888 into main Aug 16, 2026
11 of 12 checks passed
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.

2 participants