The Kalman Filter is often used to filter data where you expect some noise. It does so by looking at the previous data point and how certain we are about that data point to decide how much the current measurement should weigh in.
Or as Wikipedia explains it:
The Kalman Filter (…) is an algorithm that uses a series of measurements observed over time, containing statistical noise and other inaccuracies, and produces estimates of unknown variables that tend to be more accurate than those based on a single measurement alone…
A Good Explanation
If you are like me the math is not as intuitive as a verbal explanation. A good video on the subject is Lachlan Blackhall’s 2016 talk on the filter and an implementation in Python. I used his implementation as the foundation for my implementation in Elixir.
The algorithm as described in the original paper is recursive. Being a functional language, Elixir lends itself very well to solving problems recursively. So instead of using an agent or GenServer to store state I implemented the filter in a strictly functional manner.
I’ve barely tested the code, and it comes with no warranties. But if you can find some use for it, it’s licensed under the MIT license and can be found on my Gitlab.
All contributions and comments are welcome.