Skip to content

Validate UKF process-noise covariance shapes - #5253

Open
FlorianPfaff wants to merge 2 commits into
mainfrom
agent/validate-ukf-process-noise-shape
Open

Validate UKF process-noise covariance shapes#5253
FlorianPfaff wants to merge 2 commits into
mainfrom
agent/validate-ukf-process-noise-shape

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Bug

The core unscented Kalman filter validated measurement-noise covariance shapes during update, but added self.Q during prediction without validating its shape.

For a two-dimensional state, a vector such as Q = [0.4, 0.2] was therefore broadcast across the predicted covariance. With an otherwise diagonal covariance, NumPy produces

P + Q = [[1.4, 0.2],
         [0.4, 2.2]]

and the subsequent symmetrization turns this into a spurious cross-covariance of 0.3 instead of rejecting the malformed process-noise model.

Fix

  • coerce the configured process noise before propagating sigma points;
  • preserve scalar and length-one covariance shorthand for one-dimensional states;
  • require shape (dim_x, dim_x) for every multidimensional state;
  • use the validated covariance in the prediction.

Regression coverage

A focused NumPy-backend regression verifies that:

  • a length-two process-noise vector for a two-dimensional UKF raises a clear ValueError;
  • the failed prediction leaves the mean and covariance unchanged;
  • the existing length-one shorthand remains accepted for a one-dimensional UKF.

Validation

  • independently reproduced the silent NumPy broadcasting and resulting spurious cross-covariance;
  • branch is based directly on current main (f196ec41d1d8681e279936db9f1a0a3abfa276e7);
  • branch is 2 commits ahead and 0 behind;
  • diff is limited to the UKF core and one focused regression module;
  • GitHub Actions is authoritative for the full backend, lint, packaging, documentation, and integration matrix.

@FlorianPfaff
FlorianPfaff marked this pull request as ready for review August 7, 2026 17:54
@FlorianPfaff
FlorianPfaff enabled auto-merge (squash) August 7, 2026 17:55
auto-merge was automatically disabled August 10, 2026 14:52

Pull request was closed

@FlorianPfaff FlorianPfaff reopened this Aug 10, 2026
@FlorianPfaff
FlorianPfaff enabled auto-merge (squash) August 10, 2026 14:52
@github-actions

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 25.97s
✅ JSON prettier 7 0 0 0 1.2s
✅ JSON v8r 7 0 0 3.12s
✅ MARKDOWN markdownlint 68 0 0 0 2.02s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.63s
✅ PYTHON black 1867 88 0 0 92.31s
✅ PYTHON isort 1867 141 0 0 2.74s
✅ REPOSITORY betterleaks yes no no 2.26s
✅ REPOSITORY checkov yes no no 54.13s
✅ REPOSITORY gitleaks yes no no 17.09s
✅ REPOSITORY git_diff yes no no 0.32s
✅ REPOSITORY secretlint yes no no 84.83s
✅ REPOSITORY syft yes no no 6.08s
✅ REPOSITORY trivy-sbom yes no no 6.52s
✅ REPOSITORY trufflehog yes no no 32.76s
✅ YAML prettier 11 0 0 0 0.7s
✅ YAML v8r 11 0 0 12.29s
✅ 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

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