Principle:Pyro ppl Pyro State Space Models
| Knowledge Sources | |
|---|---|
| Domains | Gaussian Processes, State Space Models, Time Series |
| Last Updated | 2026-02-09 09:00 GMT |
Overview
State-space model representations cast Gaussian processes with Matern kernels as stochastic differential equations, enabling linear-time inference for temporal data through Kalman filtering.
Description
Gaussian processes (GPs) are powerful non-parametric models for functions, but their standard implementation has O(n^3) computational cost in the number of observations n, limiting scalability for time-series applications.
A key insight is that GPs with Matern-class kernels can be exactly represented as linear time-invariant (LTI) state-space models. The Matern kernel family, parameterized by a smoothness parameter nu, includes commonly used kernels:
- nu = 1/2: Exponential kernel (Ornstein-Uhlenbeck process)
- nu = 3/2: Once-differentiable process
- nu = 5/2: Twice-differentiable process
The equivalence works as follows: a GP with Matern-nu kernel is the solution to a stochastic differential equation (SDE) driven by white noise. This SDE can be discretized into a state-space model:
- State equation: x_t = A * x_{t-1} + q_t (state transition with noise)
- Observation equation: y_t = H * x_t + r_t (observation with noise)
where the state dimension is (nu + 1/2) for half-integer nu.
Once in state-space form, Kalman filtering provides exact inference in O(n) time, a dramatic improvement over the O(n^3) cost of standard GP inference. This enables:
- Filtering: estimating the current state given past observations.
- Smoothing: estimating past states given all observations.
- Prediction: forecasting future states.
- Parameter learning: optimizing kernel hyperparameters via marginal likelihood.
Usage
Use state-space model representations when:
- Working with temporal GP models where the Matern kernel is appropriate.
- The dataset is large (thousands of time points) and O(n^3) GP inference is too slow.
- You need online/streaming inference as new data arrives.
- Building hierarchical time-series models with GP components.
- Combining GPs with other state-space components (e.g., seasonal effects).
Theoretical Basis
Matern kernel:
# Matern-nu kernel:
# k(r) = sigma^2 * (2^{1-nu} / Gamma(nu)) * (sqrt(2*nu)*r/l)^nu * K_nu(sqrt(2*nu)*r/l)
# where r = |t - t'|, l = lengthscale, K_nu = modified Bessel function
# Special cases:
# nu = 1/2: k(r) = sigma^2 * exp(-r/l)
# nu = 3/2: k(r) = sigma^2 * (1 + sqrt(3)*r/l) * exp(-sqrt(3)*r/l)
# nu = 5/2: k(r) = sigma^2 * (1 + sqrt(5)*r/l + 5*r^2/(3*l^2)) * exp(-sqrt(5)*r/l)
SDE representation (for Matern-3/2):
# The Matern-3/2 GP f(t) solves the SDE:
# d^2f/dt^2 + 2*lambda*df/dt + lambda^2*f = sigma_w * dW/dt
# where lambda = sqrt(3)/l, W is Wiener process
# State vector: x(t) = [f(t), df/dt]^T (dimension = nu + 1/2 = 2)
# Continuous-time state-space model:
# dx/dt = F*x + L*w(t)
# F = [[0, 1], [-lambda^2, -2*lambda]]
# L = [[0], [1]]
# Observation: y = H*x, H = [1, 0]
Discretization:
# For time step dt:
# x_t = A * x_{t-1} + q_t, q_t ~ Normal(0, Q)
# y_t = H * x_t + r_t, r_t ~ Normal(0, R)
# A = matrix_exp(F * dt) (state transition matrix)
# Q = P_inf - A * P_inf * A^T (process noise covariance)
# where P_inf is the stationary covariance (solution to continuous Lyapunov equation)
# Observation noise R = sigma_obs^2
Kalman filter (O(n) inference):
# For t = 1, ..., n:
# Predict:
# m_t^- = A * m_{t-1}
# P_t^- = A * P_{t-1} * A^T + Q
# Update (if y_t observed):
# S_t = H * P_t^- * H^T + R (innovation covariance)
# K_t = P_t^- * H^T * S_t^{-1} (Kalman gain)
# m_t = m_t^- + K_t * (y_t - H * m_t^-)
# P_t = (I - K_t * H) * P_t^-
# Log marginal likelihood:
# log p(y) = sum_t -0.5 * (log|S_t| + v_t^T S_t^{-1} v_t + d*log(2*pi))
# where v_t = y_t - H * m_t^- (innovation)
# Total cost: O(n * d^3) where d = state dimension (typically 2-3)