Skip to content

add covariance calculation - #4

Open
michael-petersen wants to merge 1 commit into
ObservationalExpansions:mainfrom
michael-petersen:covariance
Open

add covariance calculation#4
michael-petersen wants to merge 1 commit into
ObservationalExpansions:mainfrom
michael-petersen:covariance

Conversation

@michael-petersen

Copy link
Copy Markdown
Collaborator

This PR simply adds a (fairly naive) implementation of covariance. Tests suggest this takes about 4x as long as computing the coefficients themselves, so be warned.

Copilot AI lite review requested due to automatic review settings August 5, 2026 12:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a covariance computation API to the flex.FLEX Laguerre/Fourier expansion implementation, allowing callers to estimate per-harmonic (m) covariance across Laguerre orders (n) using particles as observations.

Changes:

  • Added FLEX.laguerre_covariance() to compute and cache unbiased sample covariance matrices for cosine and sine terms with axes (m, n, n).
  • Updated FLEX class docstring to document the new method and the coscovariance / sincovariance attributes.
  • Added tests validating the covariance results against numpy.cov and verifying the <2 particles error case.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/test_flex.py Adds unit tests comparing laguerre_covariance() output to numpy.cov and checks the minimum-particle constraint.
src/flex/flexbase.py Implements laguerre_covariance() and documents the new cached covariance attributes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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