4 ms·
As a developer I always found these maths-first approaches to Kalman filters impenetrable (I guess that betrays my lack of knowledge, I dare cast no aspersions
by chubs 2y ago
As a developer I always found these maths-first approaches to Kalman filters impenetrable (I guess that betrays my lack of knowledge, I dare cast no aspersions on the quality of these explanations!). However, if like me, it helps with the learning curve to implement it first, here's a 1-dimensional version simplified from my blog:
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-programmers/ https://www.splinter.com.au/2023/12/14/the-kalman-filter-for...
- nextos 2y agoIt's not your fault, these can get messy very quickly. Infer.NET was started because Tom Minka and other Bayes experts were tired of writing message passing and variational inference by hand, which is both cumbersome and error prone on non-toy problems. 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/kalman_smoother_2d.ipynb https://github.com/biaslab/ForneyLab.jl/blob/master/demo/kal...
- ngriffiths 2y agoThanks for sharing this - saving this paper too (from link in the github page): https://people.ee.ethz.ch/~loeliger/localpapers/FactorGraphsProcIEEE2007.pdf https://people.ee.ethz.ch/~loeliger/localpapers/FactorGraphs... I'm not familiar with these techniques at all but seems like they have a ton of useful applications.
- nextos 2y agoFactor graphs are well discussed in David Barber's excellent free BRML book: http://web4.cs.ucl.ac.uk/staff/D.Barber/textbook/140324.pdf http://web4.cs.ucl.ac.uk/staff/D.Barber/textbook/140324.pdf Judea Pearl described it as an excellent Bayesian textbook. There's a free solutions book and everything is also implemented.