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
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