Introduction
This library provides a minimal C++ implementation of linear Gaussian state-space models (LGSSMs) and their associated algorithms, namely:
- Kalman filtering: estimating the state of a dynamical system given noisy sequential measurements.
- Rauch–Tung–Striebel (RTS) smoothing: refining the state estimates by incorporating future observations.
- Batch processing utilities for sequences of observations and controls.
1. Model formulation
We consider a linear dynamical system with additive Gaussian noise:
where:
- is the state vector at time step ,
- is an optional control input,
- is the measurement vector,
- is the state transition matrix,
- is the control-input matrix,
- is the observation matrix,
- is the process noise covariance,
- is the measurement noise covariance.
2. Kalman filtering
The Kalman filter maintains the mean and covariance of the posterior distribution under the Gaussian assumption.
Prediction step
Given the previous posterior :
Here, are the predicted state mean and covariance.
Update step
With a new measurement :
- Innovation (measurement residual):
- Innovation covariance:
- Kalman gain:
- Updated mean and covariance:
The filter proceeds recursively for each time step.
3. RTS smoothing
The Rauch–Tung–Striebel smoother refines the filtered estimates using backward recursions:
- Initialize:
- For :
This yields the posterior means/covariances given all observations .
4. What this library provides
This implementation:
- Encapsulates model parameters in a
KFConfig
struct. - Provides a
KalmanFilter
class with:- Single-step
predict()
andupdate()
. - Batch sequence filtering with
filter_sequence()
.
- Single-step
- Implements
rts_smooth_lti()
for RTS smoothing in the time-invariant case. - Uses Eigen for matrix operations.
- Focuses on clarity and minimalism for teaching, prototyping, and integration into larger C++ projects.
5. References
- R.E. Kalman, A New Approach to Linear Filtering and Prediction Problems, ASME J. Basic Eng., 1960.
- Rauch, H.E., Tung, F., and Striebel, C.T., Maximum Likelihood Estimates of Linear Dynamic Systems, AIAA Journal, 1965.