Basis of the Kalman Filter [pdf]
github.com
github.com
https://cecas.clemson.edu/~ahoover/ece854/refs/Djuric-Partic...
https://eprints.lancs.ac.uk/id/eprint/53537/1/Introduction_t...
https://ieeeoes.org/wp-content/uploads/2021/02/BPF_SPMag_07....
[0]: I'll happily talk about it at 39c3.
https://pyro.ai/examples/smcfilter.html
https://www.pymc.io/projects/examples/en/latest/samplers/SMC...
You also need for measurements to be equally spaced. Often they are – you might get an alternating pattern of measurement and observation – but often they're not, in which case the Kalman filter gives extra weight to new measurements coming in if it's been a while since it last had one (because that will have allowed the uncertainty to grow).
The Kalman filter also allows you to take into account measurements that are more uncertain in one direction than another. Think of cameras with visual recognition, which tell you a precise angle but only a rough distance estimate. If you have a couple of those and suitable measurement error matrices then the Kalman filter will automatically do a sort of triangulation.
Add a bonus, you can also use the covariance matrix of the target as information in its own right. But, as you say, often parameters are tuned for getting a good result rather than reality so the target uncertainty isn't always especially meaningful.
I wrote down a note for myself where I work this out, if anyone is interested: https://postbits.de/kalman-measurement-update.html
The Kalman filter is adding the precision (inverse of covariance) of the measurement and the precision of the predicted state, to obtain the precision of the corrected state. To do so, the respective covariance matrices are first inverted, to obtain precision matrices. To have both in the same space, the measurement precision matrix is projected to the state space using matrix H. The resulting sum is converted back to a covariance matrix, by inverting it.
This was one of the books we used: https://link.springer.com/chapter/10.1007/978-1-4757-9365-9_...
Meinhold, Richard J., and Nozer D. Singpurwalla. 1983. "Understanding the Kalman Filter." American Statistician 37 (May): 123–27.
...The answer will surprise you!
My guess is that many computer data engineers encounter them and find their self taught grasp of linear algebra and undergraduate math challenged by the theory behind K-F's .. they seem to come across as a bit of a leg up over moving averages, Savitzky–Golay, FFT applications, etc.
There are many more people dealing with implementing these things than have had formal undergraduate lectures on them.
My gut feeling is that most are more likley to encounter K-F applications in drone control, dead reckoning positions when undergound or with flakey GPS, cleaning real world data, etc. than to find themselves having to solve PDE's ..
I posit the existence of some form of pragmatic Maslow's Hierarchy of Applicable Math.
I do agree though that HN has odd bursts of Kalman filter posts.
vaguely - plenty of other imputation approaches that are simpler/better/more accessible.
> F applications in drone control, dead reckoning positions when undergound or with flakey GPS
these are not things 99% of devs encounter. literally
> dead reckoning positions when undergound or with flakey GPS
is the domain of probably like 100-1000 people in the entire world - i know because i actually have brushed up against it and am aware painfully aware of the lack of resources.
i really do think it's just a programmer l33t meme not unlike monads, category theory, etc - something that most devs think will elevate them to godhood if they can get their heads around it (when in fact it's pretty useless in practice and just taught in school as a prereq for actually useful things).
As K-filters in data processing and interpretation, that depends thoroughly on the data domains, a good number have biases and co-signals that are more easily removed with an adaptive model of some form.
Eg: magnetic heading effect when recording nine axis nano-tesla range ground signals. The readings returned over a specific point at a specific time of day are a function of sensor speed and heading. Repeated flying over the same point (hypothetically at the same time) from North to South Vs East to West returns different data streams on each of the nine channels.
To get a "true ground reading" both the heading bias and the diurnal flux must be estimated and subtracted.
> plenty of other imputation approaches that are simpler/better/more accessible.
Do tell. What would you use in the above example?
So is the Fast Fourier transform, Viterbi algorithm, dynamic programming, message passing and a trillion other things.
Kalman Filter Explained Simply (2024, 89 comments) https://news.ycombinator.com/item?id=39343746
A non-mathematical introduction to Kalman filters for programmers (2023, 97 comments) https://news.ycombinator.com/item?id=36971975
The state of the art has now been supplanted by large deep learning models in the present day, primarily relying on end-to-end trained Transformer networks.
This may be familiar to you in the context of LLMs which have recently become popular, but they were actually first successfully utilized in autonomous vehicles (invented by researchers at Google and implemented in production at Waymo almost immediately).
function transpose(a) { return a } // 1x1 matrix eg a single value.
function invert(a) { return 1/a }
const qExternalNoiseVariance = 0.1
const rMeasurementNoiseVariance = 0.1
const fStateTransition = 1
let pStateError = 1
let xCurrentState = rawDataArray[0]
for (const zMeasurement in rawDataArray) {
const xPredicted = fStateTransition * xCurrentState
const pPredicted = fStateTransition * pStateError * transpose(fStateTransition) + qExternalNoiseVariance
const kKalmanGain = pPredicted * invert(pPredicted + rMeasurementNoiseVariance)
pStateError = pPredicted - kKalmanGain * pPredicted
xCurrentState = xPredicted + kKalmanGain * (zMeasurement - xPredicted) // Output!
}
https://www.splinter.com.au/2023/12/14/the-kalman-filter-for...It helps to take a more abstract view where you split the generative process and the inference algorithm. Some frameworks (Infer.NET, ForneyLab.jl) can generate an efficient inference algorithm from the generative model without any user input. See e.g. https://github.com/biaslab/ForneyLab.jl/blob/master/demo/kal...
I'm not familiar with these techniques at all but seems like they have a ton of useful applications.
Judea Pearl described it as an excellent Bayesian textbook. There's a free solutions book and everything is also implemented.