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

Overview

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".

You might also like...
Simple neural network library for classification written in Rust.

Cogent A note I continue working on GPU stuff, I've made some interesting things there, but ultimately it made me realise this is far too monumental a

Mars is a rust machine learning library. [Goal is to make Simple as possible]
Mars is a rust machine learning library. [Goal is to make Simple as possible]

Mars Mars (ma-rs) is an blazingly fast rust machine learning library. Simple and Powerful! 🦀 🚀 Contribution: Feel free to build this project. This i

Rust implementation of real-coded GA for solving optimization problems and training of neural networks
Rust implementation of real-coded GA for solving optimization problems and training of neural networks

revonet Rust implementation of real-coded genetic algorithm for solving optimization problems and training of neural networks. The latter is also know

A neural network, and tensor dynamic automatic differentiation implementation for Rust.

Corgi A neural network, and tensor dynamic automatic differentiation implementation for Rust. BLAS The BLAS feature can be enabled, and requires CBLAS

HNSW ANN from the paper "Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphs"

hnsw Hierarchical Navigable Small World Graph for fast ANN search Enable the serde feature to serialize and deserialize HNSW. Tips A good default for

Command line interface for BDSP RNG, primarily used as a reference implementation and as a tool for testing.

BDSP RNG Reference This is a command line interface for BDSP RNG, primarily used as a reference implementation and as a tool for testing. Building Bui

scalable and fast unofficial osu! server implementation

gamma! the new bancho server for theta! built for scalability and speed configuration configuration is done either through gamma.toml, or through envi

Robust and Fast tokenizations alignment library for Rust and Python
Robust and Fast tokenizations alignment library for Rust and Python

Robust and Fast tokenizations alignment library for Rust and Python

MesaTEE GBDT-RS : a fast and secure GBDT library, supporting TEEs such as Intel SGX and ARM TrustZone

MesaTEE GBDT-RS : a fast and secure GBDT library, supporting TEEs such as Intel SGX and ARM TrustZone MesaTEE GBDT-RS is a gradient boost decision tre

Owner
SPDEs
Stochastic partial differential equations. Und wenn du lange in einen SPDEs blickst, blickt der SPDEs auch in dich hinein.
SPDEs
Allows conversion between ndarray's types and image's types

ndarray-image Allows conversion between ndarray's types and image's types Deprecated WARNING: This crate is currently deprecated in favor of https://g

Rust Computer Vision 11 Jul 26, 2022
Statistical routines for ndarray

ndarray-stats This crate provides statistical methods for ndarray's ArrayBase type. Currently available routines include: order statistics (minimum, m

null 150 Dec 26, 2022
A tour of rust's language features

Tour of Rust Welcome to the source repo of Tour of Rust. Goals This project is meant to give an experienced programmer a swift introduction to Rust as

RICHΛRD ΛNΛYΛ 693 Jan 6, 2023
Repository for CinPatent: Datasets for Patent Classification

CinPatent: Datasets for Patent Classification We release two datasets for patent classification in English and Japanese at Google Drive. The data fold

Cinnamon 1 Jan 2, 2023
A real-time implementation of "Ray Tracing in One Weekend" using nannou and rust-gpu.

Real-time Ray Tracing with nannou & rust-gpu An attempt at a real-time implementation of "Ray Tracing in One Weekend" by Peter Shirley. This was a per

null 89 Dec 23, 2022
Msgpack serialization/deserialization library for Python, written in Rust using PyO3, and rust-msgpack. Reboot of orjson. msgpack.org[Python]

ormsgpack ormsgpack is a fast msgpack library for Python. It is a fork/reboot of orjson It serializes faster than msgpack-python and deserializes a bi

Aviram Hassan 139 Dec 30, 2022
A simple neural net implementation.

PROPHET - Neural Network Library Linux Windows Codecov Coveralls Docs Crates.io A simple neural net implementation written in Rust with a focus on cac

Robin Freyler 41 Sep 16, 2022
Toy library for neural networks in Rust using Vulkan compute shaders

descent Toy library for neural networks in Rust using Vulkan compute shaders. Features Multi-dimensional arrays backed by Vulkan device memory Use Rus

Simon Brown 71 Dec 16, 2022
A Voice Activity Detector rust library using the Silero VAD model.

Voice Activity Detector Provides a model and extensions for detecting speech in audio. Standalone Voice Activity Detector This crate provides a standa

Nick Keenan 3 Apr 3, 2024
n2 is a library implementation of a feedforward, backpropagation artificial neural network.

n2 is a library implementation of a feedforward, backpropagation artificial neural network. Usage Add the following to the [dependencies] section o

Søren Mortensen 0 Feb 21, 2021