Skip to main content

Probabilistic ODE solvers using square-root Gaussian filtering and smoothing in JAX.

Project description

ODE Filters

PyPI Python CI Docs Coverage

A JAX-based implementation of probabilistic ODE solvers using Gaussian filtering and smoothing. This package provides tools for solving ordinary differential equations while quantifying uncertainty through Bayesian inference.

Features

  • Pure JAX implementation - Fully differentiable and JIT-compilable
  • Square-root filtering - Numerically stable EKF and RTS smoothing
  • Flexible priors - Integrated Wiener Process (IWP), Matern, and joint priors
  • First and second-order ODEs - Native support for both ODE types
  • Constraint handling - Conservation laws and time-varying measurements
  • State-parameter estimation - Joint inference with hidden states
  • Black-box measurements - Custom observation models with autodiff Jacobians
  • Transformed measurements - Nonlinear state transformations with chain-rule Jacobians
  • Pluggable linearization - EK0 / EK1 / IEKF corrections, selectable per solve
  • Adaptive step sizes - jit/vmap/grad-safe adaptive solving, with optional fixed-point smoothing
  • Parameter estimation - Differentiable marginal likelihood with an Optax-friendly fit API

Installation

Install the latest release from PyPI:

pip install ode-filters

Or install from source with development dependencies:

git clone https://github.com/paufisch/ode_filters.git
cd ode_filters
pip install -e ".[dev]"

Quick Example

import jax.numpy as np
from ode_filters import (
    IWP,
    ODEInformation,
    gaussian_filter,
    rts_smoother,
    taylor_mode_initialization,
)

# Define ODE: dx/dt = -x (exponential decay)
def vf(x, *, t):
    return -x

x0 = np.array([1.0])
tspan = (0.0, 5.0)  # a tuple: hashable for use as a jax.jit static argument

# Set up the prior and the ODE-information measurement model
prior = IWP(q=2, d=1, Xi=0.5 * np.eye(1))
mu_0, Sigma_0_sqr = taylor_mode_initialization(vf, x0, q=2)
measure = ODEInformation(vf, prior.E0, prior.E1)

# Filter on a fixed grid, then smooth
result = gaussian_filter(mu_0, Sigma_0_sqr, prior, measure, tspan, N=50)
m_smooth, P_smooth_sqr = rts_smoother(prior, result)

# result.m / result.P_sqr -> filtered means / square-root covariances at the grid
# result.log_likelihood   -> calibrated marginal log-likelihood

For adaptive step sizes, use gaussian_filter_adaptive(mu_0, Sigma_0_sqr, prior, measure, save_at=...) — it is jit / vmap / grad-safe; pass smoother=True to also get a fixed-point smoothing pass that rts_smoother consumes.

Package Structure

ode_filters/
├── filters/          # EKF and RTS smoothing loops
├── inference/        # Square-root Gaussian algebra
├── measurement/      # ODE and observation models
└── priors/           # Gaussian Markov process priors

Documentation

Full documentation is available at paufisch.github.io/ode_filters.

Development

Run the test suite:

uv run pytest --cov=ode_filters --cov-report=term-missing

Build documentation locally:

uv run mkdocs serve

License

MIT License - see LICENSE for details.

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

ode_filters-0.7.1.tar.gz (308.5 kB view details)

Uploaded Source

Built Distribution

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

ode_filters-0.7.1-py3-none-any.whl (69.3 kB view details)

Uploaded Python 3

File details

Details for the file ode_filters-0.7.1.tar.gz.

File metadata

  • Download URL: ode_filters-0.7.1.tar.gz
  • Upload date:
  • Size: 308.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for ode_filters-0.7.1.tar.gz
Algorithm Hash digest
SHA256 e592cf4c513a6d24af01685d4d7d2bb250efc2a2071f7c9fc56a3bdeea00b668
MD5 19240a5f569d3253959f1bb3ca9a8254
BLAKE2b-256 78f5dba4cf15437bba195fec688569412dbd8d575a1f224ea6aab2d6deb7b1ec

See more details on using hashes here.

File details

Details for the file ode_filters-0.7.1-py3-none-any.whl.

File metadata

  • Download URL: ode_filters-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 69.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for ode_filters-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 45cd93457d57c9bd7bc2b1636e758ed3b7852c77714a2e7b1b10dc8798845150
MD5 6c9eafa36fb3fc7cdd97a3bcaaf3f65b
BLAKE2b-256 050efa6dd9140ba9b4215b7c70bd9b72123b2b6938844d87de8d455bcf33c8a4

See more details on using hashes here.

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