Skip to main content

Module lgssm

Module lgssm 

Source
Expand description

Rust implementation of the Kalman filter forward pass for a linear Gaussian state-space model.

Match for KalmanFilter.filter() in src/sc_neurocore/world_model/predictive_model.py so that the Python and Rust paths return identical (within float64 round-off) means, covariances, and log-likelihood.

References match the Python module: Kalman 1960; Bishop 2006 ยง13.3.1.

Algorithm per timestep t: x_pred = A x_filt + B u P_pred = A P_filt A^T + Q e_t = y_t - C x_pred - D u S = C P_pred C^T + R K = P_pred C^T S^{-1} x_filt = x_pred + K e_t P_filt = (I - K C) P_pred (I - K C)^T + K R K^T (Joseph form) log-lik += -0.5 * (p log 2pi + log |S| + e_t^T S^{-1} e_t)

Structsยง

KalmanResult
Result of the Kalman filter forward pass.

Functionsยง

cholesky ๐Ÿ”’
Cholesky decomposition: returns L lower-triangular such that L L^T = M for symmetric PSD M. No checks on PSD-ness; if M is not PSD, the diagonal of L will contain a NaN.
invert_psd_matrix ๐Ÿ”’
Cholesky-based inversion of a symmetric PSD matrix.
kalman_filter
Run the forward Kalman filter on a sequence of observations.
log_det_psd ๐Ÿ”’
Cholesky-decomposition log-determinant of a symmetric PSD matrix.