Context
The observation model takes two channels from a dashboard-mounted lane detector: lateral lane offset and a Standard Deviation of Lane Position (SDLP) window, both in millimetres. The latent process is non-stationary in two senses: discrete switching between qualitative regimes, and slow drift within a regime. The estimator shall discriminate a regime change from within-regime drift; failure in either direction yields missed detections or alarm fatigue.
The model resides in the SPDE-GMRF repository. Figures 1 to 3 are model figures from the case study, retained in an earlier revision of the repository. Figure 4 is a CI capture from the current code. All data are simulated with fixed seeds; transition and emission parameters are illustrative and have not been fitted to recorded drives.
| Layer | Representation |
|---|---|
| Discrete | HMM over calm, alert, high stress and panic, K = 4 |
| Continuous | Gaussian field with sparse precision Q(θ) |
| Observations | Lateral lane offset and an SDLP window, both in millimetres |
Design rationale
Two latent layers

S_t under transition matrix A; field x_t with precision Q(θ). Observation y_t = μ_S + H x_t + ε_t, with ε_t ~ N(0, Σ_S) conditioned on the current regime.A plain HMM assumes conditionally independent emissions given the regime. Fatigue accumulation and varying conditions violate that assumption; absorbing the drift into the discrete layer either inflates K beyond the semantically meaningful states or produces spurious regime switches. The continuous layer carries the drift so that K remains 4 and each regime remains interpretable. The field enters the lateral offset channel only, through the lifted offset of the current site.
Direct calm-to-panic transition

N(μ_k + H x_t, Σ_k). Mass concentrates on self-transitions and nearest neighbours; the dashed arc is the direct transition a_14.a_14 exists because onset of the critical regime is not preceded by a gradual build-up. It is small by construction and is therefore the weight most exposed to int8 rounding to zero, which would render the transition unreachable for the filter. Requirement: the int8 model shall retain a nonzero a_14 after quantisation. test_transition_matrix_keeps_direct_calm_to_panic checks the requirement.
Inference decomposition

O(TK²), K = 4. Conditioned on the regimes, the field is Gaussian with sparse precision, solved by one sparse Cholesky factorisation. θ = (A, μ_k, Σ_k, κ, τ) is updated from the joint likelihood, with log|Q| = 2 Σ log L_ii taken from the same factor.The decomposition places the sparse factorisation on the field side, where it executes periodically, and reduces the per-sample path to a 4 by 4 recursion. Implemented: field-side estimation of κ and τ with log|Q| read from the factor, and the forward filter.
Results

python/tests/test_forward_filter.py (seed 7), first 600 of 5,000 samples. Panels: observation channels; simulated regime and int8 mode (offset for visibility); float forward posterior; int8 belief, dequantised as (α + 128) / 255 and normalised.| Metric (5,000 samples) | Value |
|---|---|
| int8 against float argmax agreement | 99.66% |
| Mean absolute belief error | 0.0020 |
| Maximum absolute belief error | 0.1265 |
| Accuracy against simulated regime, float filter | 0.9234 |
| Accuracy against simulated regime, int8 filter | 0.9240 |
| Floor hits | 0 |
| Cost per sample | 40 MACs, independent of field size |
Observations
- Regime changes are not separable by inspection of the observation channels. Near sample 300 both channels widen sharply; elsewhere the excursions are comparable to the noise floor. A fixed threshold is therefore insufficient.
- The int8 mode tracks the simulated regime, including the transitions to panic near samples 80 and 300, with transient disagreement confined to transition boundaries.
- The float posterior and the int8 belief are indistinguishable at plot scale. int8 quantisation of the filter does not alter the MAP decision.
- Zero floor hits: the fixed-point rescale prevented belief underflow over the full run.
Limitations
- The int8 quantiser rounds transition weights without a floor. A nonzero
a_14is guaranteed only under a floor-at-one rule, which the repository's Lean proof sketch proves sufficient and which is not yet implemented. Plain rounding maps everya_14below 1/254 to zero. - Backward sampling and the EM or Laplace update of
A,μ_kandΣ_kare not implemented; regime parameters are fixed. - The closed loop (CARLA scene rendering, OpenCV lane detection producing lateral offset and SDLP, GPU R-CNN detection, and a microcontroller receiving features over UART, updating the regime belief and returning the estimate to the simulation) exists as a design only.
- Implemented: the model, the filter, and firmware bit-exact with the Python reference under QEMU for Cortex-M4F. GPU timing, on-device timing and accuracy on recorded drives are not measured.
Source:

