https://github.com/TuringLang/SSMProblems.jl
State space programming
https://github.com/TuringLang/SSMProblems.jl
Last synced: 9 months ago
JSON representation
State space programming
- Host: GitHub
- URL: https://github.com/TuringLang/SSMProblems.jl
- Owner: TuringLang
- License: mit
- Created: 2024-08-01T00:30:12.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-09-27T12:54:32.000Z (9 months ago)
- Last Synced: 2025-09-27T14:43:02.705Z (9 months ago)
- Language: Julia
- Homepage:
- Size: 3.37 MB
- Stars: 5
- Watchers: 4
- Forks: 3
- Open Issues: 37
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- License: LICENSE
Awesome Lists containing this project
README
# SSMProblems.jl
[](https://github.com/invenia/BlueStyle)
[](https://github.com/JuliaTesting/Aqua.jl)
| Package | Docs |
| :--------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| SSMProblems | [](https://turinglang.org/SSMProblems.jl/SSMProblems/dev/) |
| GeneralisedFilters | [](https://turinglang.org/SSMProblems.jl/GeneralisedFilters/dev/)|
A minimalist framework to define state space models (SSMs) and their associated
log-densities to feed into inference algorithms.
## Talk at [LAFI 2025](https://popl25.sigplan.org/details/lafi-2025/11/State-Space-Model-Programming-in-Turing-jl)
[PDF Slides](https://github.com/user-attachments/files/20160397/LAFI_2025_Presentation.pdf)
[](https://www.youtube.com/watch?v=58DsScclqGU
)
## Basic interface
This package defines the basic interface needed to run inference on state space
as the following:
```julia
# Wrapper for model dynamics and observation process
abstract type LatentDynamics end
abstract type ObservationDynamics end
# Define the initialisation/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(dyn, obs)
```
For specific details on the interface, please refer to the package [documentation](https://turinglang.github.io/SSMProblems.jl/dev).
## 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.
```julia
using SSMProblems, Distributions
# Model parameters
sig_u, sig_v = 0.1, 0.2
struct LinearGaussianLatentDynamics <: LatentDynamics end
# Initialisation distribution
function distribution(dyn::LinearGaussianLatentDynamics, extra::Nothing)
return Normal(0.0, sig_u)
end
# Transition distribution
function distribution(
dyn::LinearGaussianLatentDynamics,
step::Int,
state::Float64,
extra::Nothing
)
return Normal(state, sig_u)
end
struct LinearGaussianObservationProcess <: ObservationProcess end
# Observation distribution
function distribution(
obs::LinearGaussianObservationProcess,
step::Int,
state::Float64,
extra::Nothing
)
return Normal(state, sig_v)
end
```