JAX implementation of Extended Kalman Filter(EKF). JAX is used for its ability to automatically calculate jacobian through jax.numpy.jacfwd
. There is also an EKF code written with Numpy instead of JAX, where jacobian matrix has to be calculated by hand and then be explicitly given as argument in the code. This code was created as an assignment from lecture DEEE0728-001(Statistical inference and machine learning), KNU Fall 2022.
- jax 0.3.14
- matplotlib 3.5.3
- tqdm
- numpy (for numpy version of EKF)
The Kalman filter iteratively estimates the state from measurements of linear system and measurement model with additive white gaussian noise(AWGN).
state at time k | |
measurement at time k | |
|
|
|
(1) Mean/Covariance matrix of vector random variable
where
(2) Mean/Covariance matrix of sum of vector random variable
where
(3) Conditional Gaussian
State Transition | |
---|---|
Measurement |
where
Kalman filter essentially updates the posterior distribution of the state for each measurements same as Density Propagation, then use Bayesian Optimal Estimator(Posterior Mean) to estimate the current state of the system.
Let the previous posterior as
From state transition model
Using formula (1), (2)
From measurement model
Using formula (1), (2)
Joint distribution of
Using formala (3)
We call term
where
Here we discard transpose in
At each time step, the KF trys to predict state estimation
Prediction step (before measurement |
Predict |
Correction step (after measurement |
Correct |
The extended Kalman filter (EKF) is a widely used algorithm for estimating the state of a dynamic system when the system and measurement models are non-linear. It allows for the incorporation of non-linear models into the Kalman filter framework by linearizing the models around the current estimate of the state.
State Transition | |
---|---|
Measurement |
where
Consider a non-linear system model of the form:
This linearized model is given by:
where
Similarly, consider a non-linear measurement model of the form:
where
where
With these linearized models, we can proceed with the Kalman filter as usual, using the prediction and correction steps described below.
At each time step, the EKF trys to predict state estimation
Prediction step (before measurement |
Predict |
Correction step (after measurement |
Correct |
Here,
One important consideration when using the extended Kalman filter is the choice of the process and measurement noise covariances,