Smoothers
- class stonesoup.smoother.base.Smoother(transition_model: TransitionModel = None)[source]
Bases:
Base
Smoother Base Class
(Fixed interval) Smoothers in general are used to infer a state, or series of states, \(\mathbf{x}_k\) from measurements \(\mathbf{z}_{1:K}\) where \(k < K\).
The calculation is forward-backward in nature. The forward algorithm is “standard” filtering, provided by other Stone Soup components. The Smoother’s input is therefore a
Track
(created by whatever means) Thesmooth()
function undertakes the backward algorithm.- Parameters:
transition_model (
TransitionModel
, optional) – Transition Model.
- transition_model: TransitionModel
Transition Model.
Kalman
- class stonesoup.smoother.kalman.KalmanSmoother(transition_model: LinearGaussianTransitionModel)[source]
Bases:
Smoother
The linear-Gaussian or Rauch-Tung-Striebel smoother, colloquially the Kalman smoother [1]. The transition model is therefore linear-Gaussian. No control model is currently implemented.
TODO: Include a control model
The smooth function undertakes the backward algorithm on a
Track()
object. This is done by starting at the final index in the track, \(K\) and proceeding from \(K \rightarrow 1\) via:\[ \begin{align}\begin{aligned}\mathbf{x}_{k|k-1} &= F_{k} \mathbf{x}_{k-1}\\P_{k|k-1} &= F_{k} P_{k-1} F_{k}^T + Q_{k}\\G_k &= P_{k-1} F_{k}^T P_{k|k-1}^{-1}\\\mathbf{x}_{k-1}^s &= \mathbf{x}_{k-1} + G_k (\mathbf{x}_{k}^s - \mathbf{x}_{k|k-1})\\P_{k-1}^s &= P_{k-1} + G_k (P_{k}^s - P_{k|k-1}) G_k^T\end{aligned}\end{align} \]where \(\mathbf{x}_{K}^s = \mathbf{x}_{K}\) and \(P_K^s = P_K\).
The predicted state vector and covariance are retrieved from the Track via predicted state or updated state via the links therein. Note that this means that the first two equations are not calculated, the results merely retrieved. This smoother is therefore strictly Kalman only in the backward portion. The prediction might have come by any number of means. If present, the transition model (providing \(F\) and \(Q\)) in the prediction is used. This allows for a dynamic transition model (i.e. one that changes with \(k\)). Otherwise, the (static) transition model is used, defined on smoother initialisation.
References
- Parameters:
transition_model (
LinearGaussianTransitionModel
) – The transition model. Thesmooth()
function will initially look for a transition model in the prediction. If that is not found then this one is used.
- transition_model: LinearGaussianTransitionModel
The transition model. The
smooth()
function will initially look for a transition model in the prediction. If that is not found then this one is used.
- class stonesoup.smoother.kalman.ExtendedKalmanSmoother(transition_model: TransitionModel)[source]
Bases:
KalmanSmoother
The extended version of the Kalman smoother. The equations are modified slightly, analogously to the extended Kalman filter,
\[ \begin{align}\begin{aligned}\mathbf{x}_{k|k-1} &= f_{k} (\mathbf{x}_{k-1})\\F_k &\approx J_f (\mathbf{x}_{k-1})\end{aligned}\end{align} \]where \(J_f (\mathbf{x}_{k-1})\) is the Jacobian matrix evaluated at \(\mathbf{x}_{k-1}\). The rest of the calculation proceeds as with the Kalman smoother.
In fact the first equation isn’t calculated – it’s presumed to have been undertaken by a filter when building the track; similarly for the predicted covariance. In practice, the only difference between this and the Kalman smoother is in the use of the linearised transition matrix to calculate the smoothing gain.
- Parameters:
transition_model (
TransitionModel
) – The transition model to be used.
- transition_model: TransitionModel
The transition model to be used.
- class stonesoup.smoother.kalman.UnscentedKalmanSmoother(transition_model: TransitionModel, alpha: float = 0.5, beta: float = 2, kappa: float = 0)[source]
Bases:
KalmanSmoother
The unscented version of the Kalman filter. As with the parent version of the Kalman smoother, the mean and covariance of the prediction are retrieved from the track. The unscented transform is used to calculate the smoothing gain.
- Parameters:
transition_model (
TransitionModel
) – The transition model to be used.alpha (
float
, optional) – Primary sigma point spread scaling parameter. Default is 0.5.beta (
float
, optional) – Used to incorporate prior knowledge of the distribution. If the true distribution is Gaussian, the value of 2 is optimal. Default is 2kappa (
float
, optional) – Secondary spread scaling parameter. Default is calculated as 3-Ns
- transition_model: TransitionModel
The transition model to be used.