# explanation of kalman filter

I have gone through my lecture notes but I can't seem to figure out the five different steps of a Kalman filter and how these steps are Divided into prediction and correction and how the state and the uncertainty evolves with each step. I would appreciate it if someone could explain it to me please

The Kalman filter applies to situations where we want to track a process state using a sequence of measurements (observations). The Kalman filter gives us a recursive way to estimate the process state.

Broadly, the Kalman update can be separated into a predict stage and an update stage.

In the prediction stage, we carry our estimates of the state forward in the absence of new measurements.

To start the prediction, we have an estimate of the state mean and the state error covariance. This is either from initialization conditions or from a previous update step. Further, we also have knowledge of the system dynamics, i.e. we have a model for how the system will evolve. Using this, we calculate ('predict') what the new value for the state will be.

Starting from the previous estimate of the state mean, we revise our estimate of the state mean using the system dynamics. This calculating is called prediction because we are estimating the state value in the future without any new measurements to guide us. This prediction of the state mean is the first part of the predict stage.

The system model often has some source of uncertainty (process noise term). We do not know what values this noise term took. We track this increase in uncertainty by revising (predicting) the state error covariance. This is second part of prediction stage.

Now we can move on to the update stage. The update stage is run only in the circumstance that we obtain a new measurement. We want to use this measurement to glean some information regarding the true value of the state. Then, we want to update the state estimate (mean), and state error covariance so that we are ready to go back to the prediction.

The update step can be broadly split into 3 steps. 1. To get the information out, we calculate the 'innovation' i.e. difference between the measurement and the predicted value for the measurement. 2. We calculate a Kalman gain filter (some understanding of the MMSE estimator is helpful to track the math here). 3. Then, we update the state mean by applying the innovation. Think of this as a correction to our estimate of the state based on the observation. Similarly we update the covariance of the state error. This is to reflect the decrease in uncertainty of the state from the observation.

To understand the above steps in Kalman filters, you might find it helpful to review MMSE estimators and conditional means. There are plenty of youtube videos on these topics. I suggest you start there. It will make the update steps very intuitive.

A couple of related comments.

In typical textbook examples, the Kalman filter is presented as a sequence of [predict, update, predict, update, ...]. In robotics practice, it is more common to see something like [predict, predict, ..., update, predict, predict,...] i.e. we have a lot more prediction than update, because measurements are often sporadic.

The state space of a Kalman filter is constructed with a lot of care. We want to it to be sufficiently detailed so that, conditioned on the state, the future evolution of the process is independent of the past observations. On the other hand, we want the state to be a minimal representation so that the calculations are easier. Since this influences several design choices, this is something to keep in mind.

Here is a video by Professor Michel Van Biezen that I found very useful while reading up on Kalman filter. It also includes an example problem along with the steps needed very clearly defined.