Skip to content

feat(core): own reusable covariance standardization - #1721

Closed
seonghobae wants to merge 4 commits into
mainfrom
fix/covariance-standardization-contract-1720
Closed

feat(core): own reusable covariance standardization#1721
seonghobae wants to merge 4 commits into
mainfrom
fix/covariance-standardization-contract-1720

Conversation

@seonghobae

@seonghobae seonghobae commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Superseded

Closed unmerged in favor of #1722. Both PRs implement issue #1720 from the same protected-main base, but #1722 removes the undocumented binary64 tolerances and correlation clamping present on this branch. Before closing this lane, #1722 also preserved this PR's unique external public-contract evidence: the exact fast_mlsirm.covariance_standardization@1.0.0 identity, scalar scale-invariance and fail-closed admission, known matrix recovery, multiplicative scale invariance, and malformed-input coverage. The numerical heuristics from this branch are intentionally not carried forward.

Closes #1720 only through the surviving #1722 lane; this PR itself is not merged and supplies no predecessor-head gate evidence.


Closes #1720.

Canonical-owner repair

TEPP #475 currently places scalar covariance standardization inside psychometric_core::event_time, although the arithmetic is reusable static psychometric computation. This PR moves the canonical numerical ownership to mlsirm-core; TEPP retains event-time admission and temporal composition through an adapter after a released version exists.

No TEPP type, clock, state equation, provider API, database contract, or product-specific model name is imported here.

TDD lineage

  • RED 738d3e5e7aa63b75f664fd17d9f422441bfa65e6: external crate tests require a versioned covariance_standardization public contract before the module exists. They require scalar scale invariance, known matrix recovery, multiplicative scale invariance, and typed fail-closed malformed inputs.
  • GREEN e2ec9e8766b3dec46f4d4db9665b34849c3baf2e + 6d7fcc264036aa9e2b89d07292bed1403c6cd129: implement and expose the domain-neutral Rust kernel.
  • Research/ownership trace f811b42631abed273d767841696887832f5159e2.

The hosted exact-current-head jobs remain landing authority; the source-level RED commit is preserved lineage, not a claim that hosted CI executed on that failing commit.

Numerical contract

fast_mlsirm.covariance_standardization@1.0.0 exposes:

  • standardize_variance(v) for finite v > 0, evaluating (v / sqrt(v)) / sqrt(v) rather than hard-coding 1;
  • standardize_covariance_matrix(Σ, n) for row-major symmetric covariance input, implementing D^{-1/2} Σ D^{-1/2};
  • typed failures for invalid shape, non-finite values, non-positive variance, material asymmetry, impossible pairwise covariance and non-finite output;
  • sequential division by marginal standard deviations so a finite correlation is not rejected merely because multiplying two large standard deviations would overflow;
  • exact-symmetric output and a documented pairwise-bound check without overstating that this routine proves full PSD.

External tests span f64::MIN_POSITIVE through f64::MAX, a known 2x2 result, 1e100 scale invariance and malformed numeric inputs.

Research boundary

Driver, Oud, & Voelkle (2017), DOI 10.18637/jss.v077.i05, and the associated ctsem standardization path provide the motivating TEPP use case. The generic covariance-to-correlation identity is owned here; ctsem names and EventTime semantics are deliberately excluded.

Downstream migration gate

TEPP must not consume this PR head as a production dependency. After this contract is merged and released/versioned, TEPP can replace #475's duplicate static arithmetic with an EventTime adapter and parity tests against the preserved TIPREDVARstd fixtures. Until then #475 remains non-production migration evidence.

Protected base at creation: main@45627700c26c29bca150896a9519a9b7426acb56.
Exact head at creation: f811b42631abed273d767841696887832f5159e2.

No self-approval, protection bypass, or predecessor-head evidence transfer.

@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

[Canonical owner] Add static covariance-standardization kernel for TEPP TIPREDVARstd migration

1 participant