rlabbe / filterpy

Python Kalman filtering and optimal estimation library. Implements Kalman filter, particle filter, Extended Kalman filter, Unscented Kalman filter, g-h (alpha-beta), least squares, H Infinity, smoothers, and more. Has companion book 'Kalman and Bayesian Filters in Python'.
MIT License
3.23k stars 614 forks source link

Generalized sigma-points #247

Closed FelipeGiro closed 2 years ago

FelipeGiro commented 2 years ago

Implemented Generalized sigma-points

Source:

This is a part of my research. I am investigating continuous representation for structural reliability, that usually is a exponential distribution. So, this method partially solve my problem, because it estimates quite accurately the first 4 statistical moments of most distributions. Perhaps it is interesting to have it in filterpy.

Soon, I will test it for UKF and push it into tests, but for some rapid tests I did here, it work pretty well.

Where were basically two modifications:

  1. In _sigmapoints.py, added a class GeneralizedSigmaPoints.
  2. In _test/testukf.py, added three tests for this method: test_generalized_sigma_points_weights_1D, test_generalized_sigma_points_2D, and test_generalized_sigma_points_2D_positively_constrained. These tests are reproductions of papers examples.

Note that is necessary for this method the use of the first 4 moments. So far, you have to add x and P twice, first in the class initialization and then in _sigmapoints function. It has a warning when the values are different. Perhaps it is better to exclude the inputs in _sigmapoints function.

This library helped me a lot to understand Kalman Filters, so I would like to contribute somehow.

rlabbe commented 2 years ago

I reverted this pull request. I am getting unit test errors when running py.test.

If you want to fix these and resubmit that is fine. I do ask that the py.test routines follow PEP conventions - two blank lines after functions, spaces after commas, etc.