Skip to main content

kalbee

kalbee logo

kalbee is a clean, modular Python implementation of Kalman Filters and related estimation algorithms. Designed for simplicity and performance, it provides a standard interface for state estimation in various applications.

Features

  • 10 Filters: KF, EKF, UKF, Particle Filter, Ensemble KF, Information Filter, Alpha-Beta-Gamma, Adaptive KF, Square-Root KF (SRKF), and Vectorized KF (VKF)
  • Estimators: Interacting Multiple Model (IMM) filter blending/switching estimator
  • RTS Smoother: Rauch-Tung-Striebel backward smoother for post-processing
  • Metrics: RMSE, NEES, NIS, Log-Likelihood for filter diagnostics
  • Experiment Runner: Compare filters on synthetic signals with one line
  • AutoFilter Factory: Switch between filters by name
  • Numerical Stability: Joseph form covariance updates, Cholesky factor stabilization, and symmetry enforcement
  • NumPy/SciPy Integration: Optimized for numerical computations

Installation

pip install kalbee

Or from source:

git clone https://github.com/MinLee0210/kalbee.git
cd kalbee
pip install -e .

Optional extras: pip install "kalbee[yolo]" (object-tracking examples), "kalbee[viz]" (plotting), or "kalbee[docs]" (documentation site).

Quick Start

1. Standard Kalman Filter

import numpy as np
from kalbee import KalmanFilter

state = np.zeros((2, 1))  # [position, velocity]
cov = np.eye(2)
F = np.array([[1, 1], [0, 1]])  # Constant velocity model
Q = np.eye(2) * 0.01
H = np.array([[1, 0]])
R = np.array([[0.1]])

kf = KalmanFilter(state, cov, F, Q, H, R)
kf.predict()
kf.update(np.array([[1.2]]))
print(f"Estimated State:\n{kf.x}")

2. Interacting Multiple Model (IMM) Filter

import numpy as np
from kalbee import KalmanFilter, InteractingMultipleModel

# Define CV and CA filters with shared state size (6D)
# CV model setup
kf_cv = KalmanFilter(state_init, cov_init, F_cv, Q_cv, H, R)
# CA model setup
kf_ca = KalmanFilter(state_init, cov_init, F_ca, Q_ca, H, R)

model_transition = np.array([[0.95, 0.05], [0.05, 0.95]])
model_probabilities = np.array([0.8, 0.2])

imm = InteractingMultipleModel([kf_cv, kf_ca], model_transition, model_probabilities)
imm.predict()
imm.update(measurement)

3. Vectorized Kalman Filter (Batched Tracking)

import numpy as np
from kalbee import VectorizedKalmanFilter

batch_size = 1000
state = np.zeros((batch_size, 2, 1))
covariance = np.repeat(np.eye(2)[np.newaxis, :, :], batch_size, axis=0)

# Load batched models and predict
vkf = VectorizedKalmanFilter(state, covariance, F_batch, Q_batch, H_batch, R_batch)
vkf.predict()
vkf.update(batched_measurements)

4. Compare Filters with Experiments

from kalbee import run_experiment

report = run_experiment(
    signal="sine",
    filters=["kf", "ekf", "ukf", "pf"],
    noise_std=0.5,
)
print(report.summary())

5. AutoFilter Factory

from kalbee import AutoFilter

kf = AutoFilter.from_filter(state, cov, F, Q, H, R, mode="kf")
# Available modes: kf, ekf, ukf, abg, pf, enkf, if, akf, srkf, vkf

Documentation

Full documentation with theory, code examples, and experiments for each filter:

pip install mkdocs-material
mkdocs serve

Testing

uv run pytest tests/                                  # run the suite
uv run pytest tests/ --cov=kalbee --cov-report=term   # with coverage

License

This project is licensed under the Apache License 2.0.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kalbee-0.4.1.tar.gz (40.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kalbee-0.4.1-py3-none-any.whl (40.7 kB view details)

Uploaded Python 3

File details

Details for the file kalbee-0.4.1.tar.gz.

File metadata

  • Download URL: kalbee-0.4.1.tar.gz
  • Upload date:
  • Size: 40.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for kalbee-0.4.1.tar.gz
Algorithm Hash digest
SHA256 64fd0b811ac839958b53719f049d6526d1df0a45cf31112bf6534e38a512960e
MD5 cfb9a0180a68ea4c1e0b69917e7714eb
BLAKE2b-256 ab73f2860787271b6f3c5f70b49e02e9e058f79039e7dfb60c3665583ecbfcc9

See more details on using hashes here.

File details

Details for the file kalbee-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: kalbee-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 40.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for kalbee-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6deaa40ad8db08f7f081f79694311a7c4c59a4183ce557be4d0d213332e91246
MD5 3e410243bf05fafb8b96e0cd6b65671b
BLAKE2b-256 52f098a800190b2182667f9c07e042c12f80bf1b9690509a10379e9e79342f84

See more details on using hashes here.

Release history Release notifications | RSS feed

0.6.0

2 files

0.5.0

2 files

This release

0.4.1 This release

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page