Robust Filtering and Smoothing with Gaussian Processes
Marc Peter Deisenroth, Ryan Turner, Marco F. Huber, Uwe D. Hanebeck, Carl Edward Rasmussen
I Introduction
Filtering and smoothing in context of dynamic systems refers to a Bayesian methodology for computing posterior distributions of the latent state based on a history of noisy measurements. This kind of methodology can be found, e.g., in navigation, control engineering, robotics, and machine learning . Solutions to filtering and smoothing in linear dynamic systems are well known, and numerous approximations for nonlinear systems have been proposed, for both filtering and smoothing .
In this article, we focus on Gaussian filtering and smoothing in Gaussian process (GP) dynamic systems. GPs are a robust non-parametric method for approximating unknown functions by a posterior distribution over them . Although GPs have been around for decades, they only recently became computationally interesting for applications in robotics, control, and machine learning .
The contribution of this article is the derivation of a novel, principled, and robust Rauch-Tung-Striebel (RTS) smoother for GP dynamic systems, which we call the GP-RTSS. The GP-RTSS computes a Gaussian approximation to the smoothing distribution in closed form. The posterior filtering and smoothing distributions can be computed without linearization or (small) sampling approximations of densities .
We provide numerical evidence that the GP-RTSS is more robust than state-of-the-art nonlinear Gaussian filtering and smoothing algorithms including the extended Kalman filter (EKF) , the unscented Kalman filter (UKF) , the cubature Kalman filter (CKF) , the GP-UKF , and their corresponding RTS smoothers. Robustness refers to the ability of an inferred distribution to explain the “true” state/measurement.
The paper is structured as follows: In Secs. I-A–I-B, we introduce the problem setup and necessary background on Gaussian smoothing and GP dynamic systems. In Sec. II, we briefly introduce Gaussian process regression, discuss the expressiveness of a GP, and explain how to train GPs. Sec. III details our proposed method (GP-RTSS) for smoothing in GP dynamic systems. In Sec. IV, we provide experimental evidence of the robustness of the GP-RTSS. Sec. V concludes the paper with a discussion.
In this article, we consider discrete-time stochastic systems
where is the state, is the measurement at time step , is Gaussian system noise, is Gaussian measurement noise, is the transition function (or system function) and is the measurement function. The discrete time steps run from 0 to . The initial state of the time series is distributed according to a Gaussian prior distribution . The purpose of filtering and smoothing is to find approximations to the posterior distributions , where in a subindex abbreviates with during filtering and during smoothing. In this article, we consider Gaussian approximations of the latent state posterior distributions . We use the short-hand notation where denotes the mean and denotes the covariance, denotes the time step under consideration, denotes the time step up to which we consider measurements, and denotes either the latent space () or the observed space ().
I-B Gaussian RTS Smoothing
Given the filtering distributions , , a sufficient condition for Gaussian smoothing is the computation of Gaussian approximations of the joint distributions , .
In Gaussian smoothers, the standard smoothing distribution for the dynamic system in Eqs. (1)–(2) is always
Depending on the methodology of computing this joint distribution, we can directly derive arbitrary RTS smoothing algorithms, including the URTSS , the EKS , the CKS , a smoothing extension to the CKF , or the GP-URTSS, a smoothing extension to the GP-UKF . The individual smoothers (URTSS, EKS, CKS, GP-based smoothers etc.) simply differ in the way of computing/estimating the means and covariances required in Eqs. (4)–(6) .
To derive the GP-URTSS, we closely follow the derivation of the URTSS . The GP-URTSS is a novel smoother, but its derivation is relatively straightforward and therefore not detailed in this article. Instead, we detail the derivation of the GP-RTSS, a robust Rauch-Tung-Striebel smoother for GP dynamic systems, which is based on analytic computation of the means and (cross-)covariances in Eqs. (4)–(6).
In GP dynamics systems, the transition function and the measurement function in Eqs. (1)–(2) are modeled by Gaussian processes. This setup is getting more relevant in practical applications such as robotics and control, where it can be difficult to find an accurate parametric form of and , respectively . Given the increasing use of GP models in robotics and control, the robustness of Bayesian state estimation is important.
II Gaussian Processes
In the standard GP regression model, we assume that the data have been generated according to , where and is independent (measurement) noise. GPs consider a random function and infer a posterior distribution over from data. The posterior is used to make predictions about function values for arbitrary inputs .
Similar to a Gaussian distribution, which is fully specified by a mean vector and a covariance matrix, a GP is fully specified by a mean function and a covariance function
which specifies the covariance between any two function values. Here, denotes the expectation with respect to the function . The covariance function is also called a kernel.
Unless stated otherwise, we consider a prior mean function and use the squared exponential (SE) covariance function with automatic relevance determination
Although the SE covariance function and the zero-prior mean function are common defaults, they retain a great deal of expressiveness. Inspired by , we demonstrate this expressiveness and show the correspondence of our GP model to a universal function approximator: Consider a function
where . Note that in the limit is represented by infinitely many Gaussian-shaped basis functions along the real axis with variance and prior (Gaussian) random weights , for , and for all . The model in Eq. (10) is considered a universal function approximator. Writing the sums in Eq. (10) as an integral over the real axis , we obtain
where is a white-noise process and is a Gaussian convolution kernel. The function values of are jointly normal, which follows from the convolution . We now analyze the mean function and the covariance function of , which fully specify the distribution of . The only random variables are the weights . Computing the expected function of this model (prior mean function) requires averaging over and yields
since . Hence, the mean function of equals zero everywhere. Let us now find the covariance function. Since the mean function equals zero, for any we obtain
From Eqs. (13) and (15), we see that the mean function and the covariance function of the universal function approximator in Eq. (10) correspond to the GP model assumptions we made earlier: a prior mean function and the SE covariance function in Eq. (9) for a one-dimensional input space. Hence, the considered GP prior implicitly assumes latent functions that can be described by the universal function approximator in Eq. (11). Examples of covariance functions that encode different model assumptions are given in .
II-B Training via Evidence Maximization
For target dimensions, we train GPs assuming that the target dimensions are independent at a deterministically given test input (if the test input is uncertain, the target dimensions covary): After observing a data set , for each (training) target dimension, we learn the hyper-parameters of the covariance function and the noise variance of the data using evidence maximization : Collecting all hyper-parameters in the vector , evidence maximization yields a point estimate . Evidence maximization automatically trades off data fit with function complexity and avoids overfitting .
From here onward, we consider the GP dynamics system setup, where two GP models have been trained using evidence maximization: , which models the mapping , see Eq. (1), and , which models the mapping , see Eq. (2). To keep the notation uncluttered, we do not explicitly condition on the hyper-parameters and the training data in the following.
III Robust Smoothing in Gaussian Process Dynamic Systems
Analytic moment-based filtering in GP dynamic systems has been proposed in , where the filter distribution is given by
for . Here, we extend these filtering results to analytic moment-based smoothing, where we explicitly take nonlinearities into account (no linearization required) while propagating full Gaussian densities (no sigma/cubature-point representation required) through nonlinear GP models.
In the following, we detail our novel RTS smoothing approach for GP dynamic systems. We fit our smoother in the standard frame of Eqs. (4)–(6). For this, we compute the means and covariances of the Gaussian approximation
to the joint , after which the smoother is fully determined . Our approximation does not involve sampling, linearization, or numerical integration. Instead, we present closed-form expressions of a deterministic Gaussian approximation of the joint distribution in Eq. (19).
Using the system Eq. (1) and integrating over all three sources of uncertainties (the system noise, the state , and the system function itself), we apply the law of total expectation and obtain the marginal mean
The expectations in Eq. (20) are taken with respect to the posterior GP distribution and the filter distribution at time step . Eq. (20) can be rewritten as with is the posterior mean function of . Writing as a finite sum over the SE kernels centered at all training inputs , the predicted mean for each target dimension is
where is the filter distribution at time . Moreover, , , are the training set of , is the covariance function of for the th target dimension (GP hyper-parameters are not shared across dimensions), and . For dimension , denotes the kernel matrix (Gram matrix), where , . Moreover, are the training targets, and is the learned system noise variance. The vector has been pulled out of the integration since it is independent of . Note that serves as a test input from the perspective of the GP regression model.
For the SE covariance function in Eq. (9), the integral in (21) can be computed analytically (other tractable choices are covariance functions containing combinations of squared exponentials, trigonometric functions, and polynomials). The marginal mean is given as
, being the solution to the integral in Eq. (21). Here, is the signal variance of the th target dimension of , a learned hyper-parameter of the SE covariance function, see Eq. (9).
III-A2 Marginal Covariance Matrix
We now explicitly compute the entries of the corresponding covariance . Using the law of total covariance, we obtain for
where we exploited in the last term that the system noise has mean zero. Note that Eq. (25) is the sum of the covariance of (conditional) expected values and the expectation of a (conditional) covariance. We analyze these terms in the following.
The covariance of the expectations in Eq. (25) is
where we used that . With and , we obtain
Following , the entries of are given as
where we defined , , and .
The expected covariance in Eq. (25) is given as
since the noise covariance matrix is diagonal. Following our GP training assumption that different target dimensions do not covary if the input is deterministically given, Eq. (29) is only non-zero if , i.e., Eq. (29) plays a role only for diagonal entries of . For these diagonal entries (), the expected covariance in Eq. (29) is
Hence, the desired marginal covariance matrix in Eq. (25) is
We have now solved for the marginal distribution in Eq. (19). Since the approximate Gaussian filter distribution is also known, it remains to compute the cross-covariance to fully determine the Gaussian approximation in Eq. (19).
III-B Cross-Covariance
By the definition of a covariance and the system Eq. (1), the missing cross-covariance matrix in Eq. (19) is
where is the mean of the filter update at time step and is the mean of the time update, see Eq. (20). Note that we explicitly average out the model uncertainty about . Using the law of total expectations, we obtain
where we used the fact that is the mean function of , which models the mapping , evaluated at . We thus obtain
Writing as a finite sum over kernels and moving the integration into this sum, the integration in Eq. (37) turns into
for each state dimension . With the SE covariance function defined in Eq. (9), we compute the integral analytically and obtain
where we defined , such that . In the definition of , is a hyper-parameter of responsible for the variance of the latent function in dimension . Using the definition of in Eq. (24), the product of the two Gaussians in Eq. (38) results in a new (unnormalized) Gaussian with
Pulling all constants outside the integral in Eq. (38), the integral determines the expected value of the product of the two Gaussians, . For , we obtain
Using , see Eq. (23), and some matrix identities, we finally obtain
With the mean and the covariance of the joint distribution given by Eqs. (22), (33), (39), and the filter step, all necessary components are provided to compute the smoothing distribution analytically .
IV Simulations
In the following, we present results analyzing the robustness of state-of-the art nonlinear filters (Sec. IV-A) and the performances of the corresponding smoothers (Sec. IV-B).
We consider the nonlinear stochastic dynamic system
which is a modified version of the model used in . The system is modified in two ways: First, Eq. (40) does not contain a purely time-dependent term in the system, which would not allow for learning stationary transition dynamics. Second, we substituted a sinusoidal measurement function for the originally quadratic measurement function used by and . The sinusoidal measurement function increases the difficulty in computing the marginal distribution if the time update distribution is fairly uncertain: While the quadratic measurement function can only lead to bimodal distributions (assuming a Gaussian input distribution), the sinusoidal measurement function in Eq. (41) can lead to an arbitrary number of modes—for a broad input distribution.
The prior variance was set to , i.e., the initial uncertainty was fairly high. The system and measurement noises (see Eqs. (40)–(41)) were relatively small considering the amplitudes of the system function and the measurement function. For the numerical analysis, a linear grid in the interval $(\mu_{0}^{x})_{i}i=1,\dotsc,100x_{0}^{(i)}{p}(x_{0}^{(i)})=\mathcal{N}((\mu_{0}^{x})_{i},\sigma_{0}^{2})i=1,\dotsc,100$.
For the dynamic system in Eqs. (40)–(41), we analyzed the robustness in a single filter step of the EKF, the UKF, the CKF, an SIR PF (sequential importance resampling particle filter) with 200 particles, the GP-UKF, and the GP-ADF against the ground truth, closely approximated by the Gibbs-filter . Compared to the evaluation of longer trajectories, evaluating a single filter step makes it easier to analyze the robustness of individual filtering algorithms.
Tab. LABEL:tab:evaluation_nonlinear_system summarizes the expected performances (RMSE: root-mean-square error, MAE: mean-absolute error, NLL: negative log-likelihood) of the EKF, the UKF, the CKF, the GP-UKF, the GP-ADF, the Gibbs-filter, and the SIR PF for estimating the latent state . The results in the table are based on averages over 1,000 test runs and 100 randomly sampled start states per test run (see experimental setup). The table also reports the 95% standard error of the expected performances. The indicates a method developed in this paper. Tab. LABEL:tab:evaluation_nonlinear_system indicates that the GP-ADF is the most robust filter and statistically significantly outperforms all filters but the sampling-based Gibbs-filter and the SIR PF. The green color highlights a near-optimal Gaussian filter (Gibbs-filter) and the near-optimal particle filter. Amongst all other filters the GP-ADF is the closest Gaussian filter to the computationally expensive Gibbs-filter . Note that the SIR PF is not a Gaussian filter and is able to express multi-modality in distributions. Therefore, its performance is typically better than the one of Gaussian filters. The difference between the SIR PF and a near-optimal Gaussian filter, the Gibbs-filter, is expressed in Tab. LABEL:tab:evaluation_nonlinear_system. The performance difference essentially depicts how much we lose by using a Gaussian filter instead of a particle filter. The NLL values for the SIR PF are obtained by moment-matching the particles.
The poor performance of the EKF is due to linearization errors. The filters based on small sample approximations of densities (UKF, GP-UKF, CKF) suffer from the degeneracy of these approximations, which is illustrated in Fig. 1. Note that the CKF uses a smaller set of cubature points than the UKF to determine predictive distributions, which makes the CKF statistically even less robust than the UKF.
IV-B Smoother Robustness
where is the moment of inertia and the acceleration of gravity. Then, the successor state
Note that the scalar measurement Eq. (44) solely depends on the angle. Thus, the full distribution of the latent state had to be reconstructed using the cross-correlation information between the angle and the angular velocity.
We experimented with even smaller signal-to-noise ratios. The GP-RTSS remains robust, while the other smoothers remain unstable.
V Discussion and Conclusion
In this paper, we presented GP-RTSS, an analytic Rauch-Tung-Striebel smoother for GP dynamic systems, where the GPs with SE covariance functions are practical implementations of universal function approximators. We showed that the GP-RTSS is more robust to nonlinearities than state-of-the-art smoothers. There are two main reasons for this: First, the GP-RTSS relies neither on linearization (EKS) nor on density approximations (URTSS/CKS) to compute an optimal Gaussian approximation of the predictive distribution when mapping a Gaussian distribution through a nonlinear function. This property avoids incoherent estimates of the filtering and smoothing distributions as discussed in Sec IV-A. Second, GPs allow for more robust “system identification” than standard methods since they coherently represent uncertainties about the system and measurement functions at locations that have not been encountered in the data collection phase. The GP-RTSS is a robust smoother since it accounts for model uncertainties in a principled Bayesian way.
After training the GPs, which can be performed offline, the computational complexity of the GP-RTSS (including filtering) is for a time series of length . Here, is the size of the GP training sets, and and are the dimensions of the state and the measurements, respectively. The computational complexity is due to the inversion of the and -dimensional covariance matrices, and the computation of the matrix in Eq. (28), required for each entry of a and -dimensional covariance matrix. The computational complexity scales linearly with the number of time steps. The computational demand of classical Gaussian smoothers, such as the URTSS and the EKS is . Although not reported here, we verified the computational complexity experimentally. Approximating the online computations of the GP-RTSS by numerical integration or grids scales poorly with increasing dimension. These problems already appear in the histogram filter . By explicitly providing equations for the solution of the involved integrals, we show that numerical integration is not necessary and the GP-RTSS is a practical approach to filtering in GP dynamic systems.
Although the GP-RTSS is computationally more involved than the URTSS, the EKS, and the CKS, this does not necessarily imply that smoothing with the GP-RTSS is slower: function evaluations, which are heavily used by the EKS/CKS/URTSS are not necessary in the GP-RTSS (after training). In the pendulum example, repeatedly calling the ODE solver caused the EKS/CKS/URTSS to be slower than the GP-RTSS (with 250 training points) by a factor of two.
The increasing use of GPs for model learning in robotics and control will eventually require principled smoothing methods for GP models. To our best knowledge, the proposed GP-RTSS is the most principled GP-smoother since all computations can be performed analytically exactly, i.e., without function linearization or sigma/cubature point representation of densities, while exactly integrating out the model uncertainty induced by the GP distribution.
Code will be made publicly available at http://mloss.org.
Acknowledgements
This work was partially supported by ONR MURI grant N00014-09-1-1052, by Intel Labs, and by DataPath, Inc.