Skip to content

Add monomial<->Hermite/Chebyshev basis conversion and statistical moments - #33

Open
andreapasquale94 wants to merge 6 commits into
mainfrom
claude/basis-conversion-moments-n8lzx2
Open

Add monomial<->Hermite/Chebyshev basis conversion and statistical moments#33
andreapasquale94 wants to merge 6 commits into
mainfrom
claude/basis-conversion-moments-n8lzx2

Conversation

@andreapasquale94

Copy link
Copy Markdown
Owner

Adds tax::toHermite/fromHermite and tax::toChebyshev/fromChebyshev for
dense, isotropic expansions, via a shared separable connection-coefficient
driver (tax/core/basis/). Also adds tax::la::mean/covariance/skewnessTensor/
kurtosisTensor/excessKurtosisTensor (tax/la/moments.hpp), which extract
statistical moments of a polynomial map assuming i.i.d. standard-normal
expansion variables, computed directly from monomial coefficients via
closed-form Gaussian raw moments (Isserlis'/Wick's theorem).

Motivated by Michelotti, Burnett & Topputo, "Analytical Confidence Boundaries
for Non-Gaussian Uncertainty in Perturbed Spacecraft Dynamics" (arXiv:2607.10095),
which uses a monomial-to-Hermite transform and Isserlis' theorem for the same
purpose; the moments implementation here takes an independently-verifiable
route (direct Gaussian raw moments) rather than porting the paper's specific
Hermite-tensor formulas, since arXiv was unreachable from this environment.

Includes unit tests (round-trips, textbook polynomial identities, and
hand-verified chi-square(1) moments) and internals/guide/reference docs.

claude added 5 commits July 15, 2026 05:55
…ents

Adds tax::toHermite/fromHermite and tax::toChebyshev/fromChebyshev for
dense, isotropic expansions, via a shared separable connection-coefficient
driver (tax/core/basis/). Also adds tax::la::mean/covariance/skewnessTensor/
kurtosisTensor/excessKurtosisTensor (tax/la/moments.hpp), which extract
statistical moments of a polynomial map assuming i.i.d. standard-normal
expansion variables, computed directly from monomial coefficients via
closed-form Gaussian raw moments (Isserlis'/Wick's theorem).

Motivated by Michelotti, Burnett & Topputo, "Analytical Confidence Boundaries
for Non-Gaussian Uncertainty in Perturbed Spacecraft Dynamics" (arXiv:2607.10095),
which uses a monomial-to-Hermite transform and Isserlis' theorem for the same
purpose; the moments implementation here takes an independently-verifiable
route (direct Gaussian raw moments) rather than porting the paper's specific
Hermite-tensor formulas, since arXiv was unreachable from this environment.

Includes unit tests (round-trips, textbook polynomial identities, and
hand-verified chi-square(1) moments) and internals/guide/reference docs.
Change skewnessTensor / kurtosisTensor / excessKurtosisTensor to return
Eigen::Tensor<T,3> (D×D×D) and Eigen::Tensor<T,4> (D×D×D×D) from Eigen's
unsupported/Eigen/CXX11/Tensor module, instead of std::vector-of-matrices
slices. Access is now the natural S(i,j,k) / K(i,j,k,l).

The tensors are fully symmetric, so each value is computed once over sorted
index tuples and scattered to every distinct permutation via
std::next_permutation (which also collapses repeated indices). Since every
tuple is a permutation of exactly one sorted tuple, this writes every entry,
so no zero-initialization pass is needed.

Adds a multivariate symmetry test exercising the permutation scatter and
off-diagonal cross-moments; updates guide/internals/reference docs.
Switch skewnessTensor / kurtosisTensor / excessKurtosisTensor from
dynamic-size Eigen::Tensor<T,R> to fixed-size
Eigen::TensorFixedSize<T, Eigen::Sizes<D,...>>, and covariance from a
dynamic Eigen::MatrixXd to a fixed Eigen::Matrix<T,D,D>. The map dimension
D is taken from Derived::SizeAtCompileTime; a dynamic-size input map is now
rejected with a static_assert.

Fixed-size returns are stack-allocated with compile-time shape, matching the
library's fixed-shape, allocation-free convention. Tests gain static_asserts
pinning the exact fixed-size return types; docs updated accordingly.
Add vector-returning tax::la::skewness / kurtosis / excessKurtosis, each a
fixed-size D x 1 Eigen vector of the standardized marginal coefficient for
every output component: Fisher skewness E[(F_i-mu_i)^3]/sigma_i^3, Pearson
kurtosis E[(F_i-mu_i)^4]/sigma_i^4 (3 for a Gaussian marginal), and its
excess (-3) form (0 for a Gaussian marginal).

These are the diagonal of the corresponding central-moment tensors,
normalized by the appropriate power of sigma_i, but computed directly per
component (O(D) evaluations instead of building the O(D^3)/O(D^4) tensor).
They complement the existing skewnessTensor/kurtosisTensor joint-moment
tensors. Tests and guide/internals/reference docs updated.
Remove tax/la/moments.hpp from the <tax/la.hpp> include list so it is no
longer pulled in transitively by <tax/tax.hpp>. moments.hpp depends on
Eigen's heavy unsupported/Eigen/CXX11/Tensor module, and there is no reason
for every umbrella consumer to pay that compile-time cost.

Consumers that want statistical moments now include the header explicitly:
    #include <tax/la/moments.hpp>

Update the moments test to include it directly, and note the opt-in include
requirement in the header comment and the guide/internals/reference docs.
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.73404% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 97.05%. Comparing base (71a7ef1) to head (5b46c84).

Files with missing lines Patch % Lines
include/tax/la/moments.hpp 99.47% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #33      +/-   ##
==========================================
+ Coverage   96.82%   97.05%   +0.22%     
==========================================
  Files          87       93       +6     
  Lines        3530     3906     +376     
  Branches      477      567      +90     
==========================================
+ Hits         3418     3791     +373     
  Misses         37       37              
- Partials       75       78       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Add tax::la::correlation(F), the fixed-size D x D Pearson correlation matrix
Corr(F_i, F_j) = Cov(F_i, F_j) / (sigma_i sigma_j) with a unit diagonal, and
tax::la::correlationFromCovariance(C), a standalone conversion that normalizes
any plain-scalar covariance matrix to a correlation matrix (returning the same
Eigen shape). correlation(F) is a thin wrapper composing covariance(F) with
that conversion.

The conversion is constrained to arithmetic-scalar matrices so it never
overload-collides with the map-taking correlation. A zero-variance component
yields a non-finite row/column (correlation undefined). Adds tests (correlated
and uncorrelated maps, plus a direct hand-built cov->corr conversion) and
updates the guide/internals/reference docs.
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