
How a Kalman filter works, in pictures - gballan
https://www.bzarg.com/p/how-a-kalman-filter-works-in-pictures/
======
mjburgess
The use of color to impart additional semantics in mathematical equations, at
least to this degree, is not something I have considered before.

This is going to change a lot in how I communicate with math.

~~~
djmips
Kind of like Stuart Riffle's colorized Fourier Transform. (version here ->
[https://blog.revolutionanalytics.com/2014/01/the-fourier-
tra...](https://blog.revolutionanalytics.com/2014/01/the-fourier-transform-
explained-in-one-sentence.html))

archived with artifacts here ->
[https://web.archive.org/web/20120418231513/http://www.altdev...](https://web.archive.org/web/20120418231513/http://www.altdevblogaday.com/2011/05/17/understanding-
the-fourier-transform/)

------
pgt
I built a smart volume control system out of distributed Kalman filters +
classic PID control to track the EBU-128 loudness envelope of an unknown sound
source and attenuate the music gain to keep it at a comfortable level:
[https://wallfly.webflow.io/](https://wallfly.webflow.io/)

The challenge comes when dealing with silence, or breaks in a song: if you
detect silence, should the volume go up or down? Of course, the dynamics make
the music and should not change, but you don't know that without access to the
source signal. So you add latency to the PID controller, but then you get
overshoot (classic time/accuracy trade-off).

To do perfect control you need access to the source signal, or lookahead, but
you can still do a pretty good job without the source signal by capping the
signal gain, i.e. only attenuate and never add amplify. Still compresses the
signal, though.

There are some clever tricks used in radar systems that you can use to
estimate the noise in a room, like coherence:
[https://en.wikipedia.org/wiki/Coherence_(signal_processing)](https://en.wikipedia.org/wiki/Coherence_\(signal_processing\)).

In an LTI (linear time-invariant system), coherence can compare the
acceleration of both input and output signals to calculate the power (but not
the contents) of external signals that entered the system.

Coherence, is in my opinion, underused in industry.

------
xaedes
When implementing Kalman filters a common issue is that the covariance matrix
P retards to be not positive semi-definite due to numerical errors. When this
happens the Kalman filter may result REALLY weird results.

There is an easy fix for this that is rarely mentioned, except one runs into
this issue and googles it: After updating (prediction and observation) P just
ensure its positive semi-definiteness by averaging with its transpose:

P := (P+transpose(P))/2

~~~
rmrfstar
What you have recommended will tend to stabilize the covariance matrix, but
not for the reason you have given. If numerical stability is an issue you
encounter, I would caution against using it. Try [1] instead.

You imply that any symmetric matrix is positive semi-definite. Take an
orthogonal matrix U and a diagonal matrix D with one or more negative values.

P = U * D * U.T is symmetric but not positive semi-definite.

For example, if D[0,0] = -1 then U[:, 0].T * P * U[:,0] = -1.

[1]
[https://en.wikipedia.org/wiki/Kalman_filter#Square_root_form](https://en.wikipedia.org/wiki/Kalman_filter#Square_root_form)

------
timeinput
I recommend this article frequently when someone is looking to learn about
Kalman filters. It's got some nice I intuition building descriptions. I also
like [https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-
Pyt...](https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python)

------
The_rationalist
The latest innovative mainstream use of a Kalman filter that I'm aware of is
from a Microsoft contribution to chromium, for better tracking the mouse:
[https://chromium-
review.googlesource.com/c/chromium/src/+/18...](https://chromium-
review.googlesource.com/c/chromium/src/+/1822657)

------
xchip
Nice, I wrote an article too that helps develop an intuition without much math

[https://aguaviva.github.io/KalmanFilter/KalmanFilter.html](https://aguaviva.github.io/KalmanFilter/KalmanFilter.html)

~~~
rrss
> What if we can only carry one sensor?

> That is what happened exactly in the Apollo rocket, back in the 60s the IMUs
> were veeery heavy and they could only carry one.

The first and most famous application of a Kalman filter in the Apollo program
was for the problem of midcourse navigation. In this application, the Apollo
PGNCS used the Kalman filter to combine the calculated trajectory based on
vehicle dynamics with the sextant measurements (optical starsighting). The IMU
was not used for midcourse navigation.

See e.g. Figures 1-6 and 5-5 in
[http://klabs.org/history/history_docs/mit_docs/1697.pdf](http://klabs.org/history/history_docs/mit_docs/1697.pdf).

------
msadowski
If you want to learn Kalman Filter in depth then I can recommend the open
source interactive book Kalman and Bayesian Filters in Python
[https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-
Pyt...](https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python)

------
isatty
When I used to develop Kalman filters, visualizing the covariances was the
best way to understand/debug the setup. Two great libraries that I used were
eigen3 (for the filter) and point cloud library
([https://pointclouds.org/](https://pointclouds.org/)) for visuals.

------
bionhoward
Yes, and I love the pictures, but I wish they had a key attached, with the
simple English name of each variable in the equation, because it’s no fun to
hunt around a long article for the definition of a one letter variable. Common
problem on Arxiv

------
ogogmad
See my recent submission on particle filters for an alternative to Kalman
filters:
[https://news.ycombinator.com/item?id=23948245](https://news.ycombinator.com/item?id=23948245)

------
carrolldunham
One thing the textbooks and explainers never seem to think to do is start with
the one-dimensional case. All the confronting looking matrix equations reduce
to an intuitive, even obvious set of arithmetic operations.

~~~
em500
Indeed. The simplest one-dimensional case of the Kalman filter is just
exponential smoothing, which you can implement and tweak in a spreadsheet.
Unfortunately the leap to the general multivariate case is still pretty big.

------
SturgeonsLaw
I enjoy these sorts of articles, but man no matter how many times I read one
the mathematical equations just look like hieroglyphics to me

~~~
082349872349872
Equation reading speed should be _much_ slower than explication reading speed,
which is in turn normally slower than prose reading speed.

(Compare with reading music: one can derive value from passages embedded in
text without being able to sight-read, but one ought to make the effort to
play them nevertheless.)

------
ezconnect
This video series helped me finally understand how to use Kalman Filters.
[https://www.youtube.com/watch?v=CaCcOwJPytQ](https://www.youtube.com/watch?v=CaCcOwJPytQ)

------
bl0b
Great article. I've been trying to grok the Kalman filter for a while now,
definitely seems to have clicked a little more this time. BTW if the author
sees this the link at the bottom 'Some credit and referral should be given
to...' seems to be broken.

------
doomrobo
(2015)

