Skip to main content

Overview of cd-dynamax

PyPI version Python versions Tests License: MIT

The primary goal of this codebase is to extend dynamax to a continuous-discrete (CD) state-space-modeling setting, that is, to problems where

  • the underlying dynamics are continuous in time,
  • and measurements can arise at arbitrary (i.e., non-regular) discrete times.

To address these gaps, cd-dynamax modifies dynamax to accept irregularly sampled data and implements classical algorithms for continuous-discrete filtering and smoothing.

Mathematical Framework: continuous-discrete state-space models

In this repository, we build an expanded toolkit for filtering, forecasting and learning dynamical systems that underpin real-world messy time-series data.

We move towards this goal by working with the following flexible mathematical setting:

  • We assume there exists a (possibly unknown) stochastic dynamical system of form

$$dx(t) = f(x(t), u(t), t)dt + L(x(t), u(t), t) dw(t)$$

where $x \in \mathbb{R}^{d_x}$, $x(0) \sim p(x_0; \varphi_{x_0})$, $f$ is a possibly time-dependent drift function, $L$ is a possibly state and/or time-dependent diffusion coefficient, $u(t)$ denotes optional input covariates, and $dw$ is the derivative of a $d_x$-dimensional Brownian motion with covariance $Q$.

  • We assume data are available at arbitrary times $\{t_k\}_{k=1}^K$ and observed via a measurement process dictated by

$$p(y(t_k) \mid x(t_k), u(t_k), t_k; \varphi_y)$$

The library provides the Gaussian model classes ContDiscreteLinearGaussianSSM and ContDiscreteNonlinearGaussianSSM, together with a ContDiscreteNonlinearSSM class for generic initial conditions and observation distributions.

We denote the collection of all parameters as $\theta = \{f,\ L,\ \varphi_{x_0},\ Q,\ \varphi_y \}$.

Note:

  • The Gaussian model classes ContDiscreteLinearGaussianSSM and ContDiscreteNonlinearGaussianSSM use Gaussian observation noise.

    • At a high level, $\varphi_y$ collects the corresponding emission mean and covariance parameters.
    • These models remain in the standard continuous (dynamics) - discrete (observation) setting with conditionally independent observation noise across observation times.
  • ContDiscreteNonlinearSSM supports generic initial conditions and generic observation distributions for nonlinear CD-SSMs.

    • These observation distributions can depend on state, inputs, and time.
    • This includes non-Gaussian emissions such as Poisson observations.
  • Other extensions of the overall framework include categorical state spaces and additional non-Gaussian observation models.

    • These can fit into our broader code framework, and some related cases are already covered in dynamax, but they have not been our main focus here.

cd-dynamax goals and approach

For a given set of observations $Y_K = [y(t_1),\ \dots ,\ y(t_K)]$, we wish to:

  • Filter: estimate $x(t_K) \ | \ Y_K, \ \theta$
  • Smooth: estimate $\{x(t)\}_t \ | \ Y_K, \ \theta$
  • Predict: estimate $x(t > t_K)\ |\ Y_K, \ \theta$
  • Infer parameters: estimate $\theta \ |\ Y_K$

All of these problems are deeply interconnected.

  • In cd-dynamax, we enable filtering, smoothing, and parameter inference for a single system under multiple trajectory observations ($[Y^{(1)}, \ \dots \, \ Y^{(N)}]$).

    • In these cases, we assume that each trajectory represents an independent realization of the same dynamics-data model, which we may be interested in learning, filtering, smoothing, or predicting.
      • In the future, we would like to have options to perform hierarchical inference, where we assume that each trajectory came from a different, yet similar set of system-defining parameters $\theta^{(n)}$.
  • We implement such filtering/smoothing algorithms in an efficient, autodifferentiable framework.

    • We enable usage of modern general-purpose tools for parameter inference (e.g., stochastic gradient descent, Hamiltonian Monte Carlo).
  • In cd-dynamax, we take onto the parameter inference case by relying on marginalizing out unobserved states $\{x(t)\}_t$

    • this is a design choice of ours, other alternatives are possible.
    • This marginalization is performed (approximately, in cases of non-linear dynamics) via filtering/smoothing algorithms.

Codebase description and status

The cd-dynamax codebase extends the dynamax library to support continuous-discrete state space models, where observations are made at specified discrete times rather than at regular intervals.

.
├── cd_dynamax/                  # Source code for cd-dynamax library
│   ├── src/                     # Core source code
│   │   ├── continuous_discrete_linear_gaussian_ssm/  # CD-LGSSM models and algorithms
│   │   ├── continuous_discrete_nonlinear_gaussian_ssm/ # CD-NLGSSM models and algorithms
│   │   ├── continuous_discrete_nonlinear_ssm/ # CD-NLSSM models with generic initial/emission distributions
│   │   ├── ssm_temissions.py    # Modified SSM class for discrete emissions
│   │   └── utils/               # Utility functions and example models
│   └── dynamax/                 # Original dynamax library (as a submodule)
├── demos/                       # Python demos showcasing cd-dynamax functionality
│   ├── python/scripts/          # Python scripts for running demos
│   ├── python/notebooks/        # Jupyter notebooks for interactive demos
│   └── python/configs/          # Configuration files for demos
└── tests/                       # Tests for cd-dynamax functionality

Demos

We provide a set of demos that showcase key functionality of cd-dynamax.

These scripts and notebooks illustrate how to learn components of continuous-discrete SDEs from data.

For instance:

Tests

  • Several tests to establish cd-dynamax general functionality, as well as linear and non-linear filters/smoothers tests: e.g., checks that non-linear algorithms applied to linear problems return similar results as linear algorithms.

Makefile

  • We provide a Makefile to automate common tasks, such as running tests and demos.

  • To run all tests, simply execute:

make test
  • For linting, we use ruff:
make lint
  • We can also format files using ruff:
make clean
  • The docs can be built using mkdocs as:
make build_docs

Installation

Install from PyPI (recommended), from source in editable mode, or with a Conda-managed environment.


Option 1: Install from PyPI (recommended)

# Create and activate a virtual environment
python -m venv .venv        # or `uv venv`
source .venv/bin/activate   # on macOS/Linux
.venv\Scripts\activate      # on Windows

# Upgrade pip
pip install --upgrade pip

# Install latest release from PyPI
pip install cd-dynamax

cd-dynamax is currently not available on Conda Forge.


Option 2: Install from source (editable)

# Create and activate a virtual environment
python -m venv .venv        # or `uv venv`
source .venv/bin/activate   # on macOS/Linux
.venv\Scripts\activate      # on Windows

# Upgrade pip
pip install --upgrade pip

# Install in editable mode for local development
pip install -e .[dev]

Option 3: Conda environment + pip install

# Create and activate a Conda environment with Python 3.11
conda create -n cd_dynamax python=3.11
conda activate cd_dynamax

# Install latest release from PyPI
pip install cd-dynamax

GPU support

If you want GPU acceleration with JAX, you must install a CUDA-enabled jaxlib wheel.

Check the JAX installation docs for the exact commands for your system.


Notes

  • pip install -e . puts the repo in editable mode, so changes to source code are immediately available without reinstalling.

  • If you plan to use plotting features that rely on graphviz, make sure the system binary is installed:

    • macOS: brew install graphviz
    • Ubuntu/Debian: sudo apt install graphviz
    • Windows (conda): conda install graphviz
  • The [dev] extra installs additional developer tools (like pytest).

    • Once your environment is installed, you can run automated tests:
    pytest
    

Metadata

Release files for cd-dynamax 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cd-dynamax 0.4.1
File Size Uploaded
cd_dynamax-0.4.1.tar.gz 246.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cd-dynamax 0.4.1
File Interpreter ABI Platform
cd_dynamax-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 539.5 kB

Release files / cd_dynamax-0.4.1.tar.gz

Download URL cd_dynamax-0.4.1.tar.gz
Size 246.7 kB
Tags Source
SHA-256 checksum
How to use checksums
38b4c4705d2d066db5db61b1b895e795910626b2cc2ef65554593ac91ef367e7
BLAKE2b-256 checksum
How to use checksums
6565310309e35d53e6179c3799fffd227b725dba90cb2a9e1f837420c2b9ab33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 19, 2026.

Transparency log

Release files / cd_dynamax-0.4.1-py3-none-any.whl

Download URL cd_dynamax-0.4.1-py3-none-any.whl
Size 292.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7c75132a65462e79e6d1bf59622d1d754ab6319904b8575f82e263c72b94b62a
BLAKE2b-256 checksum
How to use checksums
bcbbaf83fd9db975ea3aa0706667f15440bc83be698f926b2de6519ce992ec6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 19, 2026.

Transparency log

Release history Release notifications | RSS feed

0.4.3

2 release files

0.4.2

2 release files

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.2.5

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page