Skip to content

Stabilize ellipsoidal positive-definiteness validation - #5365

Open
FlorianPfaff wants to merge 1 commit into
mainfrom
fix/ellipsoidal-pd-scaling-20260820
Open

Stabilize ellipsoidal positive-definiteness validation#5365
FlorianPfaff wants to merge 1 commit into
mainfrom
fix/ellipsoidal-pd-scaling-20260820

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Summary

Fix a reproducible numerical validation bug in AbstractEllipsoidalBallDistribution for positive-definite shape matrices with extreme but representable axis scales.

Bug

The constructor checked positive definiteness by applying eigvalsh directly to the raw shape matrix. For a valid diagonal matrix whose variances balance between about 4.49e307 and 2.23e-308, NumPy's symmetric eigensolver rounds the tiny positive eigenvalues to zero. The constructor therefore rejects a strictly positive-definite matrix before the existing log-Cholesky volume computation can handle it.

This is reproduced by the existing regression:

  • tests.distributions.test_ellipsoidal_ball_volume_stability::TestEllipsoidalBallVolumeStability::test_balanced_extreme_axes_avoid_intermediate_product_overflow

The NumPy 3.13 CI artifact from PR #5364 fails there with ValidationError: shape_matrix must be positive definite.

Fix

Validate positive definiteness after diagonal congruence scaling:

  1. require strictly positive diagonal entries;
  2. scale A as D^{-1/2} A D^{-1/2} using successive divisions;
  3. run eigvalsh on the balanced, unit-diagonal matrix.

For positive diagonal D, this congruence preserves inertia, so the mathematical positive-definiteness criterion is unchanged. It avoids the avoidable dynamic-range loss in the eigensolver. Singular and indefinite matrices remain rejected.

Scope

The existing stability and invalid-shape regression tests cover the changed behavior; no test-only weakening is included.

@github-actions

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Max errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 7.26s
✅ JSON prettier 7 0 0 0 0.6s
✅ JSON v8r 7 0 0 4.59s
✅ MARKDOWN markdownlint 68 0 0 0 2.08s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.41s
✅ PYTHON black 1988 15 0 0 67.47s
✅ PYTHON isort 1988 27 0 0 2.96s
✅ REPOSITORY betterleaks yes no no 1.35s
✅ REPOSITORY checkov yes no no 37.74s
✅ REPOSITORY git_diff yes no no 0.13s
✅ REPOSITORY secretlint yes no no 109.71s
✅ REPOSITORY syft yes no no 3.14s
✅ REPOSITORY trivy-sbom yes no no 2.93s
✅ YAML prettier 11 0 0 0 0.78s
✅ YAML v8r 11 0 0 15.99s
✅ YAML yamllint 11 0 0 1.02s

Notices

⚠️ Your configuration references items that have been removed from MegaLinter and are ignored: MAKEFILE_CHECKMAKE. See Removed linters to find their replacements.

See detailed reports in MegaLinter artifacts

Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx mega-linter-runner@10.0.0 --custom-flavor-setup --custom-flavor-linters PYTHON_BLACK,PYTHON_ISORT,COPYPASTE_JSCPD,JSON_V8R,JSON_PRETTIER,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,REPOSITORY_CHECKOV,REPOSITORY_GIT_DIFF,REPOSITORY_BETTERLEAKS,REPOSITORY_SECRETLINT,REPOSITORY_SYFT,REPOSITORY_TRIVY_SBOM,YAML_PRETTIER,YAML_YAMLLINT,YAML_V8R

MegaLinter is provided by OX Security
Show us your support by starring ⭐ the repository

@FlorianPfaff
FlorianPfaff marked this pull request as ready for review August 21, 2026 06:40
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.

1 participant