Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Non-Gaussian Markov GP inference

MarkovGPPrior gives Kalman-filter-based linear-time inference for stationary 1-D GPs (O(N\,d^3) rather than O(N^3)). When the observation likelihood p(y∣f)p(y \mid f) is non-Gaussian (Bernoulli for binary time-series classification, Poisson for counts, StudentT for robust regression), the closed-form Kalman update no longer applies.

The site-based view recovers linear time. Each iteration replaces the true non-Gaussian likelihood with a Gaussian site

tn(fn)∝exp⁡(λnfn−12Λnfn2)⇔N(fn∣y~n=λn/Λn,  1/Λn),t_n(f_n) \propto \exp\bigl(\lambda_n f_n - \tfrac12 \Lambda_n f_n^2\bigr) \quad \Leftrightarrow\quad \mathcal{N}\bigl(f_n \mid \tilde y_n = \lambda_n / \Lambda_n,\; 1/\Lambda_n\bigr),

runs forward Kalman filter + RTS smoother on those pseudo-observations with per-step variance 1/Λn1/\Lambda_n, and refreshes (λ,Λ)(\lambda, \Lambda) from local likelihood gradients/Hessians at the new posterior mean. Strategies (LaplaceMarkovInference, GaussNewtonMarkovInference, PosteriorLinearizationMarkov, ExpectationPropagationMarkov) differ only in how sites are refreshed.

This notebook shows Markov-Laplace on a Bernoulli time series and forecasts beyond the training window.

/home/azureuser/localfiles/pyrox/.venv/lib/python3.13/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm

Synthetic Bernoulli time series

Latent function f(t)=1.5 sin⁡(2t)+0.3 cos⁡(7t)f(t) = 1.5\,\sin(2t) + 0.3\,\cos(7t), observations yn∼Bernoulli(σ(f(tn)))y_n \sim \text{Bernoulli}(\sigma(f(t_n))) on an irregular grid.

<Figure size 880x330 with 1 Axes>

Fit Markov-Laplace

Matern-3/2 SDE prior (order=1), lengthscale 0.4, variance 1.0. Each Newton iteration runs Kalman filter + RTS smoother once.

converged: True
iterations used: 6
approximate log marginal: -53.466
posterior mean range: [-1.246, 1.188]
posterior var range:  [0.3476, 0.5669]

Predict + forecast

Predict on a fine grid that extends past the training window. The merged-grid Kalman trick handles training-grid lookups, interpolation, and forecasting under one code path.

<Figure size 1210x396 with 2 Axes>

Past the dotted line (last training point) the posterior reverts to the prior mean (zero) with the prior variance (MaternSDE.variance = 1), as expected — no observation pulls ff in any direction beyond the data.

Compare Laplace vs EP

EP matches the moments of the cavity-times-likelihood tilted distribution rather than the mode; on log-concave likelihoods the two strategies sit close.

EP converged: True, iters: 17
max |Laplace − EP| posterior mean: 0.0621
max |Laplace − EP| posterior var:  0.0229
<Figure size 880x385 with 1 Axes>

Summary

  • LaplaceMarkovInference and friends fit non-Gaussian likelihoods on MarkovGPPrior in linear time.
  • Each iteration is one Kalman filter + RTS smoother with per-step pseudo-observation variance 1/Lambda_n.
  • Predictions handle training-grid lookups, interpolation, and forecasting through one merged-grid pass.
  • Outside the training window the posterior reverts to the SDE prior — the right behavior for stationary state-space kernels.