Skip to content

TuringLang/SSMProblems.jl

Repository files navigation

SSMProblems.jl

Code Style: Blue Aqua QA

Package Docs
SSMProblems Dev
GeneralisedFilters Dev

A minimalist framework to define state space models (SSMs) and their associated log-densities to feed into inference algorithms.

Tip

We are currently refactoring the GPU implementation of our filters to make them both more flexible and performant. Whilst this is ongoing, we have removed the legacy GPU batching interface, but this can still be found pre-v0.3.1 or by viewing the repository at this state

Talk at LAFI 2025

PDF Slides

State space programming

Basic interface

This package defines the basic interface needed to run inference on state space as the following:

# Wrapper for model dynamics and observation process
abstract type StatePrior end
abstract type LatentDynamics end
abstract type ObservationDynamics end

# Define the initial distribution for the latent states
function distribution(prior::StatePrior, ...) end

# Define the transition distribution for the latent dynamics
function distribution(dyn::LatentDynamics, ...) end

# Define the observation distribution
function distribution(obs::ObservationProcess, ...) end

# Combine the latent dynamics and observation process to form a SSM
model = StateSpaceModel(prior, dyn, obs)

For specific details on the interface, please refer to the package documentation.

Linear Gaussian State Space Model

As a concrete example, the following snippet of pseudo-code defines a linear Gaussian state space model. Note the inclusion of the extra parameter in each method definition. This is a key feature of the SSMProblems interface which allows for the definition of more complex models in a performant fashion, explained in more details in the package documentation.

using SSMProblems, Distributions

# Model parameters
sig_u, sig_v  = 0.1, 0.2

struct LinearGaussianStatePrior <: StatePrior end

# Initial distribution
function distribution(
    prior::LinearGaussianStatePrior;
    kwargs...
)
    return Normal(0.0, 1.0)
end

struct LinearGaussianLatentDynamics <: LatentDynamics end

# Transition distribution
function distribution(
    dyn::LinearGaussianLatentDynamics,
    step::Int,
    state::Float64;
    kwargs...
)
    return Normal(state, sig_u)
end

struct LinearGaussianObservationProcess <: ObservationProcess end

# Observation distribution
function distribution(
    obs::LinearGaussianObservationProcess,
    step::Int,
    state::Float64;
    kwargs...
)
    return Normal(state, sig_v)
end

About

State space programming

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 10

Languages