Skip to content

Stabilize Merwe sigma-point scaling for small alpha - #4287

Closed
FlorianPfaff wants to merge 17 commits into
mainfrom
agent/stabilize-merwe-sigma-point-scale-20260713
Closed

Stabilize Merwe sigma-point scaling for small alpha#4287
FlorianPfaff wants to merge 17 commits into
mainfrom
agent/stabilize-merwe-sigma-point-scale-20260713

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Summary

  • compute the Merwe sigma-point scale directly as alpha**2 * (n + kappa)
  • avoid reconstructing it through n + (alpha**2 * (n + kappa) - n)
  • reject non-finite or unrepresentable scales and weights with clear ValueErrors
  • add a regression for a valid small positive alpha

Bug

MerweScaledSigmaPoints first formed

lambda_ = alpha**2 * (n + kappa) - n
scale = n + lambda_

For sufficiently small but representable positive scales, subtracting and re-adding n causes catastrophic cancellation. With n=2, kappa=0, and alpha=1e-9, the mathematically correct scale is 2e-18, but the current implementation rounds lambda_ to -2.0 and reconstructs scale as exactly 0.0. Construction then fails with division by zero, and sigma-point generation would collapse the spread.

Fix

Compute the positive scale directly and reuse that value for both weights and Cholesky scaling. This preserves the intended formula without the cancellation-prone round trip through lambda. The implementation also validates that the resulting scale and weights remain finite.

Validation

  • reproduced the pre-fix values: legacy scale 0.0, direct scale 2e-18
  • verified the direct scale yields finite weights and sigma offsets with radius sqrt(2e-18)
  • added backend-aware regression coverage for finite weights and nonzero sigma-point spread
  • python -m py_compile passes for the modified source and regression test
  • branch is two commits ahead of main and zero behind

@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 21.57s
✅ JSON prettier 7 0 0 0 0.95s
✅ JSON v8r 7 0 0 4.46s
✅ MARKDOWN markdownlint 68 0 0 0 1.8s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.81s
✅ PYTHON black 1490 183 0 0 89.21s
✅ PYTHON isort 1490 328 0 0 2.52s
✅ REPOSITORY betterleaks yes no no 1.99s
✅ REPOSITORY checkov yes no no 54.98s
✅ REPOSITORY gitleaks yes no no 14.48s
✅ REPOSITORY git_diff yes no no 0.22s
✅ REPOSITORY secretlint yes no no 66.38s
✅ REPOSITORY syft yes no no 5.15s
✅ REPOSITORY trivy-sbom yes no no 5.1s
✅ REPOSITORY trufflehog yes no no 31.13s
✅ YAML prettier 11 0 0 0 0.67s
✅ YAML v8r 11 0 0 11.05s
✅ YAML yamllint 11 0 0 0.61s

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 force-pushed the agent/stabilize-merwe-sigma-point-scale-20260713 branch from 3a54837 to 330a520 Compare July 13, 2026 16:34

Copy link
Copy Markdown
Owner Author

Closing as duplicate of #4289. The latter is the preferred Merwe sigma-point cancellation fix.

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