Skip to content

Fix cancellation in Merwe sigma-point scaling - #4945

Merged
FlorianPfaff merged 3 commits into
mainfrom
agent/fix-merwe-scale-cancellation-20260730
Jul 30, 2026
Merged

Fix cancellation in Merwe sigma-point scaling#4945
FlorianPfaff merged 3 commits into
mainfrom
agent/fix-merwe-scale-cancellation-20260730

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

What changed

  • compute the Merwe covariance scale directly as alpha**2 * (n + kappa) instead of reconstructing it through n + (scale - n)
  • use the direct scale consistently for sigma-point generation and weights
  • reject underflowed, overflowed, non-normalizable, or non-finite weight configurations with explicit ValueErrors
  • add focused regressions for cancellation, scale underflow/overflow, and float64 weight normalization limits

Root cause

The implementation first formed lambda = alpha**2 * (n + kappa) - n and then reconstructed the covariance factor as n + lambda. When the intended factor is small relative to n, the subtraction and re-addition lose significant digits through catastrophic cancellation.

For n=1, kappa=0, and alpha=2e-8, the intended scale is 4.0e-16, but the reconstructed scale is 4.440892098500626e-16. This inflates the scale by about 11.02% and the sigma-point displacement by about 5.37%.

Impact

Small but representable Merwe scaling parameters now produce the requested sigma-point spread instead of a rounded, wider spread. Parameter combinations that cannot produce finite and normalized float64 weights fail clearly rather than returning distorted weights or leaking ZeroDivisionError/OverflowError.

Validation

  • reproduced the pre-fix scale and spread errors in a focused numerical harness
  • verified the direct-scale calculation produces the requested ±2e-8 sigma-point offsets
  • added tests/test_sigma_points_merwe_scale_stability.py
  • branch is two commits ahead of main and zero behind; full repository CI is pending

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 26.78s
✅ JSON prettier 7 0 0 0 1.57s
✅ JSON v8r 7 0 0 3.95s
✅ MARKDOWN markdownlint 68 0 0 0 2.18s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.71s
✅ PYTHON black 1795 47 0 0 92.16s
✅ PYTHON isort 1795 76 0 0 2.7s
✅ REPOSITORY betterleaks yes no no 2.49s
✅ REPOSITORY checkov yes no no 54.24s
✅ REPOSITORY gitleaks yes no no 16.66s
✅ REPOSITORY git_diff yes no no 0.37s
✅ REPOSITORY secretlint yes no no 74.56s
✅ REPOSITORY syft yes no no 5.79s
✅ REPOSITORY trivy-sbom yes no no 6.55s
✅ REPOSITORY trufflehog yes no no 31.78s
✅ YAML prettier 11 0 0 0 0.77s
✅ YAML v8r 11 0 0 12.04s
✅ YAML yamllint 11 0 0 0.65s

Notices

📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining SECURITY_SUGGESTIONS: false)

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@9.6.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_GITLEAKS,REPOSITORY_BETTERLEAKS,REPOSITORY_SECRETLINT,REPOSITORY_SYFT,REPOSITORY_TRIVY_SBOM,REPOSITORY_TRUFFLEHOG,YAML_PRETTIER,YAML_YAMLLINT,YAML_V8R

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

@FlorianPfaff
FlorianPfaff marked this pull request as ready for review July 30, 2026 14:50
@FlorianPfaff
FlorianPfaff enabled auto-merge (squash) July 30, 2026 14:50
@FlorianPfaff
FlorianPfaff merged commit 5bd478d into main Jul 30, 2026
25 checks passed
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