How a Kalman filter works, in pictures
bzarg.com
bzarg.com
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).
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.
This is going to change a lot in how I communicate with math.
archived with artifacts here -> https://web.archive.org/web/20120418231513/http://www.altdev...
I wanted to print the webpage wihtout wasting so much ink. And a white background improves readability too.
For that I needed to learn how to manipulate the image in order to invert only the greys without altering the rest of the colors. It actually was pretty easy with Gimp (duplicate layer, choose mode: HSL Color for the upper layer, invert colors for the lower layer).
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
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
The presentation is similar to the (nice yet more verbose) notebook "01-g-h-filter.ipynb" in github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python/
> 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.
(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.)