The Curious Case of Kalman Filters

A Stepwise Implementation using Python

What are Kalman Filters?

Purpose of Kalman Filters:

Working of Kalman Filters

Gaussian:

Image for post
Image for post
Graph representing Gaussian
Image for post
Image for post
The equation for 1D Gaussian

Gaussian Characteristics:

More on Variance:

Let’s write a Gaussian function:

Shifting the Mean:

Image for post
Image for post
The mysterious cycle where the magic happens.
Image for post
Image for post
prior distribution & measurement distribution
Image for post
Image for post
The new mean.

Where is the new peak?

Image for post
Image for post
new peak.

Parameter Update:

Image for post
Image for post
The formula for measurement update.

Gaussian Motion:

Image for post
Image for post
The formula for motion update.

The Filter Pipeline:

Output: when the initial uncertainty is high

Image for post
Image for post
Result.

Plotting the Gaussian:

Image for post
Image for post
Resulting Gaussian.

How the Filter actually works:

Remember that measurement_sig(var2 or σ²) = 4 in measurement update & motion_sig(var2 or σ²) = 2 in motion update(prediction) will remain constant. Other than that each and every variable in the code will be updated at each timestep. for example, in the for loop of the filter pipeline, the mu and sig values will get updated in the measurement update and the new updated mu and sig values are then fed into the motion update(predict) function. then again when the new values are generated by the motion update(predict) function, those updated values are then fed into the measurement update(update) function and the cycle goes on till it calculates uncertainty for each and every timestep of the vehicle/object.

Research Engineer & Writer @OpenMinedorg | LinkedIn: https://www.linkedin.com/in/krunal-kshirsagar | Github: https://www.github.com/Noob-can-Compile

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store