Git Product home page Git Product logo

kalman-rust's Introduction

Kalman filter and RTS smoother in Rust (ndarray)

run

A Kalman filtering and RTS smoothing plot

This repository features a simple Kalman filter and RTS smoother (KFS) implementation in Rust by using the ndarray library.

By simple, I mean that this implementation is almost a direct translation of my past Python implementations of KFS, and I tried to keep the syntax here readable for Python/Matlab/Julia users. It on ther other hand means that this implementation would be a good starting example for you, if you are familar with Python/Matlab/Julia and is interesting to learn Rust.

Installation and run

The installation guidance of Rust can be found at this official website.

After you have Rust installed, open a terminal and run

git clone [email protected]:spdes/kalman-rust.git
cd kalman-rust
cargo run

If succeeded, you will see a figure generated as in the above.

If failed, it is very likely that you need to have openblas or Intel MKL configured in your system and change the feature of ndarray-linalg in ./Cargo.toml accordingly.

Fantastic! I want to learn more about Rust scientific computing!

Welcome to the cult!

Implementing Kalman filter and RTS smoother is a good exercise to practise a new language, as they involves basic linear algebras, such as matrix algebras and solving linear systems. In light of this, I have an article explaining the codes here line-by-line. This article is readable even if you have no experience using Rust.

As a disclaimer, in case that you want to sue me for luring you to learn Rust, please be aware that I do not promise (nor I see any evidence) that Rust would be a main-stream language for scientific computing (especially machine learning) in the future. Furthermore, the learning curve of Rust is very steep. I learnt Rust purely out of hobby and its name 1.

Benchmarks

In folder ./benchmarks you may find a few benchmark files written in Rust, Numpy, Jax, Matlab, and Julia to compare their performance on running Kalman filtering and smoothing.

In short, the most important result is that the Rust implementation is evidently faster than others when the state dimension is large (on my working computer), and there is still a room to optimise it further!

You could find detailed results and explanations in this article.

License and contact

GPL v3 or later.

Zheng Zhao, [email protected]

Footnotes

  1. Python: "the only good snake is a dead snake". โ†ฉ

kalman-rust's People

Contributors

zgbkdlm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

chenhuayou

kalman-rust's Issues

Unfair benchmarks

Rust allocates outside the benchmark whereas other paradigms do it inside.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.