Skip to main content

Framework for recursive Bayesian estimation in Python.

Project description

PyRecEst

Recursive Bayesian Estimation for Python.

PyRecEst is a Python library for recursive Bayesian estimation on Euclidean spaces and manifolds. It uses a NumPy backend by default and can also run with PyTorch or JAX backends.

Features

PyRecEst provides tools for:

  • distributions and densities on Euclidean spaces and manifolds;
  • recursive Bayesian estimators, filters, and trackers;
  • multi-target tracking (MTT) and extended object tracking (EOT);
  • evaluation of filters and trackers; and
  • sampling distributions and generating grids.

Installation

PyRecEst requires Python 3.11 or newer and earlier than Python 3.15.

Install the package from PyPI:

python -m pip install pyrecest

Optional backend and domain-specific dependencies can be installed with extras:

python -m pip install "pyrecest[pytorch_support]"
python -m pip install "pyrecest[jax_support]"
python -m pip install "pyrecest[healpy_support]"

For development from a source checkout, use Poetry or the provided conda environment:

poetry install --with dev --all-extras
# or
conda env create -f environment.yml

Quickstart

The following example runs a one-dimensional constant-velocity Kalman filter. It uses the backend abstraction exposed by pyrecest.backend, so the same code can run on supported numerical backends.

from pyrecest.backend import array, diag
from pyrecest.filters import KalmanFilter


dt = 1.0
system_matrix = array([[1.0, dt], [0.0, 1.0]])
measurement_matrix = array([[1.0, 0.0]])
system_noise_cov = diag(array([0.05, 0.01]))
measurement_noise_cov = array([[0.25]])
measurements = [0.9, 2.0, 3.1, 3.9, 5.2]

kalman_filter = KalmanFilter((array([0.0, 1.0]), diag(array([1.0, 1.0]))))

for measurement in measurements:
    kalman_filter.predict_linear(system_matrix, system_noise_cov)
    kalman_filter.update_linear(
        array([measurement]), measurement_matrix, measurement_noise_cov
    )
    print(kalman_filter.get_point_estimate())

Run the complete script with:

python examples/basic/kalman_filter.py

Documentation

The docs/ directory contains the first project documentation pages:

  • Getting started covers installation, development setup, backend selection, and running examples.
  • API overview maps the main packages and points to the most common public entry points.
  • Backend compatibility explains the NumPy, PyTorch, and JAX support model and known limitations.
  • API reference contains generated package reference pages built with MkDocs and mkdocstrings.
  • Task tutorials show common distribution, filtering, tracking, and evaluation workflows.
  • Shapes and conventions documents common vector, matrix, measurement-set, batch, and manifold-coordinate shapes.
  • Examples lists the executable examples and what each one demonstrates.

Build the documentation site locally with:

poetry install --with docs --without dev
poetry run mkdocs build --strict

Backends

PyRecEst imports pyrecest.backend dynamically. The default backend is NumPy. Set PYRECEST_BACKEND before Python imports pyrecest to select another backend:

PYRECEST_BACKEND=pytorch python examples/basic/kalman_filter.py
PYRECEST_BACKEND=jax python examples/basic/kalman_filter.py

Install the matching optional extra before using a non-default backend.

Examples and tests

  • examples/basic/kalman_filter.py contains a small executable Kalman filter example.
  • tests/ contains additional usage examples for distributions, filters, smoothers, evaluation, sampling, metrics, and tracking utilities.

To run the test suite from a development environment:

python -m pytest

Citation

If you use PyRecEst in your research, please cite:

BibTeX BibLaTeX
@misc{pfaff_pyrecest_2023,
  author       = {Florian Pfaff},
  title        = {PyRecEst: Recursive Bayesian Estimation for Python},
  year         = {2023},
  howpublished = {\url{https://github.com/FlorianPfaff/PyRecEst}},
  note         = {MIT License}
}
@software{pfaff_pyrecest_2023_software,
  author    = {Florian Pfaff},
  title     = {PyRecEst: Recursive Bayesian Estimation for Python},
  year      = {2023},
  url       = {https://github.com/FlorianPfaff/PyRecEst},
  license   = {MIT},
  keywords  = {Bayesian filtering; manifolds; tracking; Python; NumPy; PyTorch; JAX}
}

Credits

PyRecEst borrows its structure from libDirectional and follows its code closely for many classes. libDirectional, a project to which Florian Pfaff contributed extensively, is available on GitHub. The backend implementations are based on those of geomstats.

License

PyRecEst is licensed under the MIT License.

Project details


Download files

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

Source Distribution

pyrecest-2.2.1.tar.gz (494.4 kB view details)

Uploaded Source

Built Distribution

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

pyrecest-2.2.1-py3-none-any.whl (687.6 kB view details)

Uploaded Python 3

File details

Details for the file pyrecest-2.2.1.tar.gz.

File metadata

  • Download URL: pyrecest-2.2.1.tar.gz
  • Upload date:
  • Size: 494.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyrecest-2.2.1.tar.gz
Algorithm Hash digest
SHA256 7c75a30459705a52458f957a4d621a180f17b0b2ee410d931eaf75153d074103
MD5 a0df5d91bb39c2cfe2065c030063e360
BLAKE2b-256 2b56cc147e4a9448237698ea7de694cdf7ac03bd3f001e7ffebc8679bcf15800

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrecest-2.2.1.tar.gz:

Publisher: publish-to-pypi.yml on FlorianPfaff/PyRecEst

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyrecest-2.2.1-py3-none-any.whl.

File metadata

  • Download URL: pyrecest-2.2.1-py3-none-any.whl
  • Upload date:
  • Size: 687.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyrecest-2.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3697567b50e7bb7c02fa61ebb62399014b8b0ea1cd1d83a975d224ece7ed9e12
MD5 3e55ec486d21f790b569cddd1da44849
BLAKE2b-256 96d3a54a8ff654f32caf13e9e1448b8de1348efa3689390c7b1a910ac10b9c76

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrecest-2.2.1-py3-none-any.whl:

Publisher: publish-to-pypi.yml on FlorianPfaff/PyRecEst

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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