Skip to content

Transition matrix for the Kalman filter for the nth order#44

Merged
Sinitca-Aleksandr merged 22 commits intomainfrom
43-nth-order-transition-matrix
Sep 24, 2025
Merged

Transition matrix for the Kalman filter for the nth order#44
Sinitca-Aleksandr merged 22 commits intomainfrom
43-nth-order-transition-matrix

Conversation

@pipipyau
Copy link
Collaborator

No description provided.

@pipipyau pipipyau self-assigned this Aug 12, 2025
@pipipyau pipipyau added the enhancement New feature or request label Aug 12, 2025
@pipipyau pipipyau linked an issue Aug 12, 2025 that may be closed by this pull request
@pipipyau pipipyau marked this pull request as draft August 13, 2025 13:14
@Sinitca-Aleksandr
Copy link
Contributor

PR #44 Review: Transition Matrix for nth Order Kalman Filter

Overview

This PR introduces symbolic computation for Kalman filter transition matrices using SymPy, enabling support for arbitrary filter orders beyond the previously hardcoded orders 1-3. The implementation replaces manual matrix calculations with a general symbolic approach.

Key Changes

  1. New Module: StatTools/filters/symbolic_kalman.py - Implements symbolic matrix generation
  2. Enhanced Kalman Filter: Refactored get_Fget_filter_matrix with symbolic computation
  3. Dependencies: Added SymPy requirement
  4. Tests: Added validation tests for orders 2 and 3

Strengths

  • Extensibility: General solution for any filter order vs. hardcoded implementations
  • Mathematical Rigor: Uses symbolic computation for accurate matrix derivation
  • Code Quality: Follows project patterns (type hints, class-based design)
  • Testing: Includes validation against known results
  • Commit Hygiene: Proper conventional commits (feat, refactor, doc, build)

Areas for Improvement

1. Documentation

  • PR Description: Missing - should explain the mathematical approach and benefits
  • Function Docs: Some functions in symbolic_kalman.py lack complete docstrings
  • Usage Examples: No examples showing how to use higher-order filters

2. Code Quality

  • Test Cleanup: Remove debug print statement in test_kalman_filter.py
  • Error Handling: Add validation for invalid orders or parameters
  • Performance: Consider caching compiled symbolic expressions for repeated use

3. API Considerations

  • Breaking Change: Method rename get_Fget_filter_matrix affects public API
  • Backward Compatibility: Consider deprecation path if this is a public interface

4. Validation

  • Mathematical Verification: Add tests for orders > 3 to ensure correctness
  • Performance Benchmarking: Compare symbolic vs. hardcoded performance
  • Edge Cases: Test with extreme parameter values

Recommendations

  1. Complete Documentation: Add comprehensive PR description and function docs
  2. Clean Up Tests: Remove debug prints and add more comprehensive test cases
  3. Performance Optimization: Profile and optimize symbolic computation if needed
  4. Mark as Ready: Convert from draft once issues are addressed

Overall Assessment

This is a solid enhancement that significantly improves the Kalman filter implementation's flexibility. The symbolic approach is mathematically sound and well-integrated with the existing codebase. With the suggested improvements, this will be a valuable addition to the library's filtering capabilities.

Status: Requires minor revisions before approval.

@pipipyau pipipyau marked this pull request as ready for review September 24, 2025 08:06
@Sinitca-Aleksandr Sinitca-Aleksandr merged commit 27b2d39 into main Sep 24, 2025
6 checks passed
@Sinitca-Aleksandr Sinitca-Aleksandr deleted the 43-nth-order-transition-matrix branch December 16, 2025 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Transition matrix for the Kalman filter for the nth order

2 participants