Add monomial<->Hermite/Chebyshev basis conversion and statistical moments - #33
Open
andreapasquale94 wants to merge 6 commits into
Open
Add monomial<->Hermite/Chebyshev basis conversion and statistical moments#33andreapasquale94 wants to merge 6 commits into
andreapasquale94 wants to merge 6 commits into
Conversation
…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 Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.