8000 fix: use Joseph form for numerically stable covariance update by WHOIM1205 · Pull Request #211 · pykalman/pykalman · GitHub
[go: up one dir, main page]

Skip to content

fix: use Joseph form for numerically stable covariance update - #211

Open
WHOIM1205 wants to merge 1 commit into
pykalman:mainfrom
WHOIM1205:fix/joseph-form-covariance-update
Open

WHOIM1205 wants to merge 1 commit into
pykalman:mainfrom
WHOIM1205:fix/joseph-form-covariance-update

Conversation

@WHOIM1205
Copy link
Copy Markdown

Title: Use Joseph Stabilized Form for Covariance Update in _filter_correct

Summary:
Replaces the numerically unstable covariance update

P = P_pred - K @ H @ P_pred

with the Joseph stabilized form:

P = (I - K @ H) @ P_pred @ (I - K @ H).T + K @ R @ K.T

Problem:
The naive subtraction-based update suffers from catastrophic cancellation,
which can:

  • Break symmetry of the covariance matrix
  • Introduce negative eigenvalues (non-PSD covariance)
  • Cause silent corruption of filter/smoother results
  • Trigger downstream failures in EM and loglikelihood (e.g., Cholesky errors)

Impact:

  • Guarantees symmetry and positive semi-definiteness of filtered covariance
  • Prevents silent numerical degradation on ill-conditioned systems
  • Stabilizes long time-series filtering and EM convergence
  • Zero API change
  • All existing tests pass

Scope:
Minimal change (+6/-2 lines) confined to _filter_correct in
pykalman/standard.py.

Signed-off-by: WHOIM1205 <rathourprateek8@gmail.com>
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

0