 # Sequential Monte Carlo Methods for System Identification

One of the key challenges in identifying nonlinear and possibly non-Gaussian state space models (SSMs) is the intractability of estimating the system state. Sequential Monte Carlo (SMC) methods, such as the particle filter (introduced more than two decades ago), provide numerical solutions to the nonlinear state estimation problems arising in SSMs. When combined with additional identification techniques, these algorithms provide solid solutions to the nonlinear system identification problem. We describe two general strategies for creating such combinations and discuss why SMC is a natural tool for implementing these strategies.

## Authors

##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

This paper is concerned with system identification of nonlinear state space models (s) in discrete time. The general model that we consider is given by,

 xt+1∣xt ∼\fθ(xt+1∣xt,ut), (1a) yt∣xt ∼\gθ(yt∣xt,ut), (1b) (θ ∼\prior(θ)), (1c)

where the states, the known inputs and the observed measurements are denoted by , and

, respectively. The dynamics and the measurements are modeled by the probability density functions (s)

and

, respectively, parameterised by the unknown vector

. The initial state  is distributed according to some distribution . For notational simplicity, we will from hereon (without loss of generality) drop the known input from the notation. When considering Bayesian identification, meaning that

is modelled as an unobserved random variable, we also place a prior

on . We are concerned with off-line identification, we wish to find the unknown parameters  in (1) based on a batch of  measurements.

The key challenge that will drive the development throughout this paper is how to deal with the difficulty that the states in (1) are unknown. We will distinguish between two different strategies for handling this:

1. Marginalisation amounts to marginalising (integrating out) the states from the problem and viewing as the only unknown quantity of interest. In the frequentistic problem formulation, the prediction error method (Ljung, 1999) and direct maximisation of the likelihood belong to this strategy. In the Bayesian formulation, the Metropolis–Hastings algorithm (Metropolis et al., 1953; Hastings, 1970) can be used to approximate the posterior distribution of the parameters conditionally on the data.

2. Data augmentation treats the states as auxiliary variables that are estimated together with the parameters. The expectation maximisation (EM) algorithm of Dempster et al. (1977) solves the maximum likelihood formulation in this way and the Gibbs sampler of Geman and Geman (1984) solves the Bayesian problem by this strategy.

In the special case when the model (1

) is linear and Gaussian, there are closed form expressions available from the Kalman filter and the associated smoother. The primary focus of this paper, however, is the more challenging nonlinear and/or non-Gaussian case. More than two decades ago

(, Gordon et al., 1993; Kitagawa, 1993) sequential Monte Carlo () methods started to emerge with the introduction of the particle filter. These methods have since then undergone a rapid development and today they constitute a standard solution to the problem of computing the latent (unobserved/unknown/hidden) states in nonlinear/non-Gaussian s.

The aim of this paper is to show how can be used in solving the nonlinear system identification problems that arise in finding the unknown parameters in (1). We do not aim to cover all different methods that are available, but instead we aim to clearly describe exactly where and how the need for arises and focus on the key principles. Complementary overview paper are provided by Kantas et al. (2014) and by Andrieu et al. (2004).

We consider the Bayesian and the maximum likelihood formulations, as defined in Section 2. The rest of the paper is divided into three parts. In the first part (Sections 3 and 4) we describe the marginalisation and data augmentation strategies and show where the need for arise. The second part (Section 5) provides a rather self-contained derivation of the particle filter and outlines some of its properties. Finally, in the third part (Section 68) we show how these particle methods can be used to implement the identification strategies described in the first part, resulting in several state-of-the-art algorithms for nonlinear system identification. Loosely speaking, the -part of the various algorithms that we introduce is essentially a way of systematically exploring the state space in a nonlinear  (1) in order to address the key challenge of dealing with the latent state sequence .

## 2 Problem formulation

There are different ways in which the system identification problem can be formulated. Two common formalisms are grounded in frequentistic and Bayesian statistics, respectively. We will treat both of these formulations in this paper, without making any individual ranking among them. First, we consider the frequentistic, or

maximum likelihood (), formulation. This amounts to finding a point estimate of the unknown parameter , for which the observed data is as likely as possible. This is done by maximising the data likelihood function according to

 ˆθML=\argmaxθ∈\setThpθ(y1:\T)=\argmaxθ∈\setThlogpθ(y1:\T). (2)

For a thorough treatment of the use of for system identification, see , Ljung (1999); Söderström and Stoica (1989).

Secondly, in the Bayesian formulation, the unknown parameters are modeled as a random variable (or random vector) according to (1c). The system identification problem thus amounts to computing the posterior distribution of

given the observed data. According to Bayes’ theorem, the posterior distribution is given by,

 p(θ∣y1:\T)=pθ(y1:\T)\prior(θ)p(y1:\T). (3)

Note that the likelihood function should now be interpreted as the conditional of the observations given the parameters , . However, to be able to discuss the different identification criteria in a common setting, we will, with a slight abuse of notation, denote the likelihood by also in the Bayesian formulation. An early account of Bayesian system identification is provided by Peterka (1981) and a more recent description is available in Ninness and Henriksen (2010).

The central object in both formulations above is the observed data likelihood , or its constituents as,

 pθ(y1:\T)=\T∏t=1pθ(yt∣y1:t−1), (4)

where we have used the convention . For the nonlinear  (1), the likelihood (4) is not available in closed form. This is a result of the fact that the latent state sequence , , is unknown. Indeed, a relationship between the likelihood and the latent states can be obtained via marginalization of the joint density according to,

 pθ(y1:\T)=∫pθ(x1:\T,y1:\T)\mydx1:\T, (5)

where the model provides a closed form expression for the integrand according to,

 pθ(x1:\T,y1:\T)=μθ(x1)\T∏t=1\gθ(yt∣xt)\T−1∏t=1\fθ(xt+1∣xt). (6)

This expression does not involve any marginalisation, whereas the observed data likelihood

is found by averaging the joint distribution

over all possible state sequences according to (5). Equivalently, we can express as in (4) where the one-step predictive likelihood can be written (using marginalisation) as,

 pθ(yt∣y1:t−1)=∫\gθ(yt∣xt)pθ(xt∣y1:t−1)\mydxt. (7)

These expressions highlight the tight relationship between the system identification problem and the state inference problem. A key challenge that will drive the developments in this work is how to deal with the latent states. For nonlinear system identification, the need for computational methods, such as , is tightly coupled to the intractability of the integrals in (5) and (7).

To illustrate the strategies and algorithms introduced we will use them to solve two concrete problems, which are formulated below.

[Linear Gaussian model] Our first illustrative example is a simple linear Gaussian state space () model, given by

 xt+1 =0.7xt+vt, vt ∼\N(0,θ−1), (8a) yt =0.5xt+et, et ∼\N(0,0.1), (8b) (θ ∼\gam(0.01,0.01)), (8c)

where the unknown parameter corresponds to the precision

(inverse variance) of the process noise

. Note that the prior for the Bayesian model is chosen as the Gamma () distribution with known parameters, for reasons of simplicity, since this is the conjugate prior for this model. The initial distribution is chosen as the stationary distribution of the state process. Identification of is based on a simulated data set consisting of samples with true parameter .

[Nonlinear non-Gaussian model] Our second example, involving real data, is related to a problem in paleoclimatology. Shumway and Stoffer (2011) considered the problem of modelling the thickness of ice varves (layers of sediments that are deposited from melting glaciers). The silt and sand that is deposited over one year makes up one varve and changes in the varve thicknesses indicates temperature changes. The data set that is used contains the thickness of ice varves formed at a location in Massachusetts between years and  BC. We make use of a nonlinear and non-Gaussian proposed by Langrock (2011) to model this data:

 xt+1∣xt ∼N(xt+1;ϕxt,τ−1), (9a) yt∣xt ∼G(yt;6.25,0.256exp(−xt)), (9b)

with parameters . The initial distribution is chosen as the stationary distribution of the state process. The data set and a more complete description of the problem is provided by Shumway and Stoffer (2011).

## 3 Identification strategy – marginalisation

The marginalisation strategy amounts to solving the identification problem—either (2) or (3)—by computing the integral appearing in (7) (or, equivalently, (5)). That is, we marginalize (integrate out) the latent states  and view  as the only unknown quantity of interest.

In some special cases the marginalisation can be done exactly. In particular, for LGSS models the one-step predictive density in (7) is Gaussian and computable by running a Kalman filter. For the general case, however, some numerical approximation of the integral in (7) is needed. We will elaborate on this in Section 6, where we investigate the possibility of using SMC to perform the marginalisation. For now, however, to illustrate the general marginalisation strategy, we will assume that the integral in (7) can be solved exactly.

### 3.1 ML identification via direct optimisation

Consider first the ML formulation (2). Direct optimisation (DO) amounts to working directly on the problem

 ˆθML=\argmaxθ∈\setTh\T∑t=1log∫\gθ(yt∣xt)pθ(xt∣y1:t−1)\mydxt, (10)

where we have rewritten the data log-likelihood using (4) and (7). Even though we momentarily neglect the difficulty in computing the integral above it is typically not possible to solve the optimisation problem (10) in closed form. Instead, we have to resort to numerical optimisation methods, see Nocedal and Wright (2006). These methods typically find a maximiser of the log-likelihood function by iteratively refining an estimate of the maximiser according to

 \iteratesPEθk+1=\iteratesPEθk+\iteratesPEαk\iteratesPEsk. (11)

Here, denotes the search direction which is computed based on information about the cost function available from previous iterations. The step size , tells us how far we should go in the search direction. The search direction is typically computed according to

 sk=\iteratesPEHk−1\iteratesPEgk,\iteratesPEgk=∇θlogpθ(y1:\T)∣∣θ=\iteratesPEθk, (12)

where denotes a positive definite matrix (e.g. the Hessian or approximations thereof) adjusting the gradient .

[DO applied to the LGSS model] To apply the update in (10) for estimating  in (8), we need to determine search direction  and the step lengths . Here, we select the search direction as the gradient of the log-likelihood,

is the identity matrix. The log-likelihood for (

8) can be expressed as

 logpθ(y1:T)=T∑t=2logN(yt;0.5ˆxt|t−1,Pt|t−1+0.1), (13)

where and denotes the predicted state estimate and its covariance obtained from a Kalman filter. The gradient in (12) of the log-likelihood (13) can therefore be obtained by calculating and , which can be obtained from the Kalman filter, using the so-called sensitivity derivatives introduced by Åström (1980). In the upper part of LGSS:ML, we present the log-likelihood (blue) computed using the Kalman filter together with the estimate (orange) obtained by the DO algorithm. Figure 1: Upper: the log-likelihood estimates (green) together with the ML parameter estimates of the LGSS model obtain by the DO and the EM algorithms, respectively. The estimates sit on top of each other and are shown in blue. Lower: parameter posterior estimates obtained by the MH (left) and the Gibbs (right) algorithms, respectively. The vertical dashed lines indicate the true parameters of the model from which the data is generated and the dark grey lines indicate the prior density.

Within the DO method the use of arise in evaluation of the cost function in (10) and its derivatives to compute the search directions  in (12).

### 3.2 Bayesian identification via Metropolis–Hastings

Let us now turn to the Bayesian formulation (3). As above, to illustrate the idea we consider first the simple case in which the marginalisation in (7) can be done exactly. Still, in most nontrivial cases the posterior in (3) cannot be computed in closed form. The difficulty comes from the factor , known as the marginal likelihood, which ensures that the posterior is properly normalised (, that it integrates to one). The marginal likelihood can be expressed as,

 p(y1:\T)=∫pθ(y1:\T)π(θ)\mydθ. (14)

Even if the likelihood is analytically tractable, we see that we need to carry out an integration  . Furthermore, computing a point estimate, say the posterior mean of , also amounts to solving an integral

 \CExpθy1:\T=∫θp(θ∣y1:\T)\mydθ, (15)

which may also be intractable.

A generic way of approximating such intractable integrals, in particular those related to Bayesian posterior distributions, is to use a Monte Carlo method. In Section 5 we will discuss, in detail, how can be used to approximately integrate over the latents states of the system. The sequential nature of makes it particularly well suited for integrating over latent stochastic processes, such as the states in an . However, to tackle the present problem of integrating over the latent parameters

we shall consider a different class of methods denoted as Markov chain Monte Carlo ().

The idea behind is to simulate a Markov chain . The chain is constructed in such a way that its stationary distribution coincides with the so-called target distribution of interest, here . If, in addition, the chain is ergodic—essentially meaning that spatial averages coincide with “time” averages—the sample path from the chain can be used to approximate expectations to the target distribution:

 1M−k+1M∑m=kφ(\MCrealθ\iMC)\ConvAS∫φ(θ)p(θ∣y1:\T)\mydθ, (16)

as , for some test function . Here denotes almost sure convergence. Note that the first samples have been neglected in the estimator (16), to avoid the transient phase of the chain. This is commonly referred to as the burn-in of the Markov chain.

Clearly, for this strategy to be useful we need a systematic way of constructing the Markov chain with the desired properties. One such way is to use the Metropolis–Hastings () algorithm. The algorithm uses an accept/reject strategy. At iteration , we propose a new sample according to,

 \MCpropStateθ∼\proposal(⋅∣\MCrealθ\iMC), (17)

where denotes a proposal distribution designed by the user and denotes the sample from the previous iteration . The newly proposed sample will then be added to the sequence () with probability

 \acceptProb ≜1∧p(\MCpropStateθ∣y1:\T)p(\MCrealθ\iMC∣y1:\T)\proposal(\MCrealθ\iMC∣\MCpropStateθ)\proposal(\MCpropStateθ∣\MCrealθ\iMC) (18a) =1∧p\MCpropStateθ(y1:\T)\prior(\MCpropStateθ)p\MCrealθ\iMC(y1:\T)\prior(\MCrealθ\iMC)\proposal(\MCrealθ\iMC∣\MCpropStateθ)\proposal(\MCpropStateθ∣\MCrealθ\iMC), (18b)

where is used to denote and is referred to as the acceptance probability. Hence, with probability the newly proposed sample is not added to the sequence (rejected) and in that case the previous sample is once more added to the sequence .

There exists a well established theory for the algorithm, which for example establish that it is ergodic and converges to the correct stationary distribution. This has been developed since the algorithm was first introduced by Metropolis et al. (1953) and Hastings (1970). Ninness and Henriksen (2010) provides a nice account on the use of the algorithm for Bayesian system identification.

[MH applied to the LGSS model] To apply the MH algorithm for parameter inference in the LGSS model, we require a proposal distribution in (17) and to calculate the acceptance probability  in (18b). A standard choice for is a Gaussian random walk

 \proposal(\MCpropStateθ∣\MCrealθ\iMC)=\Npdf\MCpropStateθ\MCrealθ\iMCσ2q, (19)

where denotes the variance of the random walk. For this choice of proposal, the acceptance probability is

 \acceptProb=1∧p\MCpropStateθ(y1:\T)\prior(\MCpropStateθ)p\MCrealθ\iMC(y1:\T)\prior(\MCrealθ\iMC),

where cancels since it is symmetric in . Note that the likelihood can be computed using the Kalman filter in analogue with (13) for the LGSS model. In the lower left part of LGSS:ML, we present the resulting posterior estimate obtained from running the algorithm iterations (discarding the first as burn-in).

## 4 Identification strategy – Data augmentation

An alternative strategy to marginalisation is to make use of data augmentation. Intuitively, we can think of this strategy as a systematic way of separating one hard problem into two new and closely linked sub-problems, each of which is hopefully easier to solve than the original problem. For the  (1) these two problems amounts to

1. finding information about the state sequence .

2. finding information about the parameters .

The state sequence  is thus treated as an auxiliary variable that is estimated together with the parameters . Using the data augmentation terminology (Tanner and Wong, 1987; van Dyk and Meng, 2001), the state sequence is referred to as the missing data, as opposed to the observed data . By augmenting the latter with the former, we obtain the complete data .

Naturally, if the complete data were known, then identification of would have been much simpler. In particular, we can directly write down the complete data likelihood according to (6), which contrary to the observed data likelihood , does not involve any marginalisation. The two likelihoods are related via (5), suggesting that the complete data likelihood can indeed be used for identifying the unknown parameters.

### 4.1 Expectation Maximisation ()

Analogously with the marginalisation strategy, we can make use of data augmentation to address both the frequentistic and the Bayesian identification problems. For the former identification criteria, (2), the result is the expectation maximisation () algorithm (Dempster et al., 1977). provides an iterative procedure to compute estimates of unknown parameters in probabilistic models involving latent variables, like the in (1).

As a result of the conditional probability identity

 pθ(x1:\T,y1:\T)=pθ(x1:\T∣y1:\T)pθ(y1:\T),

we can relate the observed and complete data log-likelihoods as

 logpθ(y1:\T)=logpθ(x1:\T,y1:\T)−logpθ(x1:\T∣y1:\T). (20)

The algorithms operates by iteratively maximising the intermediate quantity

 \Q(θ,θ′) ≜∫logpθ(x1:\T,y1:\T)pθ′(x1:\T∣y1:\T)\mydx1:\T (21a) =\Expbθ′logpθ(x1:\T,y1:\T)∣y1:\T, (21b)

according to:

• ,

• .

We can show that iterating the above Expectation (E) and Maximisation (M) steps implies

 \Q(θ,θ′)≥\Q(θ′,θ′)⟹pθ(y1:\T)≥pθ′(y1:\T). (22)

Hence, will by construction result in a monotonic increase in likelihood values. Hence, the complete data log-likelihood can, via the intermediate quantity in (21), be used as a surrogate for the original observed data likelihood function in solving the problem (2). We are still required to compute the integral (21) and an important observation is now that we can approximate this integral (and its derivatives ) using .

[EM applied to the LGSS model] We need to compute the intermediate quantity to apply the EM algorithm for estimating the parameter in the LGSS model. For this model, we can write

 \Q(θ,θ′)=const.+\CExpbθ′logμθ(x1)+T∑t=2logN(xt;0.7xt−1,θ−1)y1:\T

Note, that this expression results from that the parameter only is present in the latent state process.

We can directly maximise the intermediate quantity for since the system is linear in the parameters. By taking the gradient of , we obtain terms proportional to , where and denotes smoothed state estimates and and their covariances, respectively. These can be computed using a Kalman smoother and we refer the reader to Gibson and Ninness (2005) for the explicit expressions for implementing this. In the upper part of LGSS:ML, we present the parameter estimate (blue) obtained by the EM algorithm. We note that the parameter estimates obtained by the DO and EM algorithms are identical and overlapping. However, they differ from the true parameter due to the finite value of .

### 4.2 Gibbs sampler

The Gibbs sampler is an method that produce samples from the joint distribution by alternatively sampling from its conditionals. Let us consider the Bayesian formulation, with the aim of computing (3). Inspired by the data augmentation strategy, start by assuming that the complete data is available. Bayes’ theorem then results in

 p(θ∣x1:\T,y1:\T)=pθ(x1:\T,y1:\T)\prior(θ)p(x1:\T,y1:\T). (23)

Intuitively, if the states  were known, then the identification problem would be much simpler and, indeed, computing the posterior in (23) is typically easier than in (3). Firstly, the complete data likelihood is provided in (6), whereas the likelihood is intractable in the general case. Secondly, in many cases of interest it is possible to identify a prior for  that is conjugate to the complete data likelihood, in which case the posterior (23) is available in closed form.

The problem with (23) is of course that it hinges upon the state sequence being known. However, assume that we can simulate a sample of the state trajectory  from its conditional distribution given the observed data and the system parameters , from the . Furthermore, assume that it is possible to sample from the distribution in (23). We can then implement the following algorithm: Initialise arbitrarily and, for ,

 Sample \MCrealx1:\T\iMC∼p\MCrealθ\iMC(x1:\T∣y1:\T). (24a) Sample \MCrealθ\iMC+1∼p(θ∣\MCrealx1:\T\iMC,y1:\T). (24b)

This results in the generation of the following sequence of random variables

 \MCrealθ0,\MCrealx1:\T0,\MCrealθ1,\MCrealx1:\T1,\MCrealθ2,\MCrealx1:\T2,…, (25)

which forms a mutual Markov chain in the parameters  and the states , . The procedure in (24) represents a valid method. More specifically, it is a particular instance of the so-called Gibbs sampler. The simulated Markov chain admits the joint distribution as a stationary distribution. Furthermore, under weak conditions it can be can be shown to be ergodic. That is, the Markov chain generated by the procedure (24) can be used to estimate posterior expectations, and the estimators are consistent in the sense of (16). Note that, if we are only interested in the marginal distribution , then it is sufficient to store the sub-sequence constituted by , obtained by simply discarding the samples from (25).

It is worth pointing out that it is possible to combine Gibbs sampling with other methods. For instance, if it is not possible to sample from posterior distribution (23) exactly, then a valid approach is to replace step (24b) of the Gibbs sampler with, , an MH step with target distribution . Similarly, for nonlinear state space models, the in (24a) is not available in closed form, but it is still possible to implement the strategy above by sampling the state trajectory from an kernel targeting the ; see Section 8.2.

[Gibbs applied to the LGSS model] To implement the Gibbs sampler for parameter inference in the LGSS model, we need to sample from the conditional distributions in (24). To generate samples of state trajectories given and , we can make use of the factorisation

 pθ(x1:\T∣y1:\T)=⎛⎝\T−1∏t=1pθ(xt∣xt+1, y1:t)⎞⎠pθ(x\T∣y1:\T) (26)

of the . Consequently, we can sample using the following backward simulation strategy: Sample and, for , sample

 \bxt∼pθ(xt∣\bxt+1, y1:t)∝pθ(\bxt+1∣xt)pθ(xt∣y1:t). (27)

We see that the backward simulation relies on the filtering distributions denoted by and, indeed, for the model we can obtain closed form expressions for all the involved densities by running a Kalman filter.

In the second step, (24b), we sample the parameters by

 θ ∼p(θ∣˜x1:\T,y1:\T)=\gam(θ∣α,β), (28a) α =0.01+T2, (28b) β =0.01+12(0.51˜x21+T−1∑t=1(˜xt+1−0.7˜xt)2), (28c)

which is the result of a standard prior-posterior update with a Gamma prior and Gaussian likelihood. The closed-form expression for is an effect of using a prior which is conjugate to the complete data likelihood.

In the lower right part of LGSS:ML, we present the resulting posterior estimate obtained from the Gibbs sampler with the same settings as for the MH algorithm. We note that the posterior estimates are almost identical for the two methods, which corresponds well to the established theory.

The data augmentation strategy (here implemented via the Gibbs sampler) enabled us to approximate the posterior distribution by separating the problem into two connected sub-problems (24).

## 5 Sequential Monte Carlo

Sequential Monte Carlo () methods offer numerical approximations to the state estimation problems associated with the nonlinear/non-Gaussian  (1). The particle filter () approximates the filtering and the particle smoother () approximates the joint smoothing , or some of its marginals. The can intuitively be thought of as the equivalent of the Kalman filter for nonlinear/non-Gaussian s.

The approximation is an empirical distribution of the form

 ˆpθ(xt∣y1:t)=\Np∑i=1\witδxit(xt). (29)

The samples are often referred to as particles—they are point-masses “spread out” in the state space, each particle representing one hypothesis about the state of the system. We can think of each particle as one possible system state and the corresponding weight contains information about how probable that particular state is.

To make the connection to the marginalisation and data augmentation strategies introduced in the two previous sections clear, we remind ourselves where the need for arise in implementing these strategies to identify  in (1). The is used to compute the cost function (10) and its derivatives in order to find the search directions (12). To set up an samler, we can make use of a likelihood estimate provided by the in order to compute the acceptance probabilities in (18). When it comes to data augmentation strategies, the is used to approximate the intermediate quantity in (21) and in order to set up the Gibbs sampler, particle methods are used to draw a realisation from the joint smoothing distribution in (24a).

### 5.1 Particle filter

A principled solution to the nonlinear filtering problem is provided by the following two recursive equations:

 pθ(xt∣y1:t) =\gθ(yt∣xt)pθ(xt∣y1:t−1)pθ(yt∣y1:t−1), (30a) pθ(xt∣y1:t−1) =∫\fθ(xt∣xt−1)pθ(xt−1∣y1:t−1)\mydxt−1. (30b)

These equations can only be solved in closed form for very specific special cases, , the model which results in the Kalman filter. We will derive the particle filter as a general approximation of (30) for general nonlinear/non-Gaussian s.

The particle filter—at least in its most basic form—can be interpreted as a sequential application of importance sampling. At each time step we use importance sampling to approximate the filtering . This is made possible by using the expressions in (30) and by exploiting the already generated importance sampling approximation of . At time we can find an empirical distribution (29) by approximating using importance sampling in the normal sense. We sample independently the particles from some proposal distribution . To account for the discrepancy between the proposal distribution and the target distribution, the particles are assigned importance weights, given by the ratio between the target and the proposal (up to proportionality), , where the weights are normalised to sum to one.

We proceed in an inductive fashion and assume that we have an empirical approximation of the filtering distribution at time according to

 ˆpθ(xt−1∣y1:t−1)=\Np∑i=1\wit−1δxit−1(xt−1). (31)

Inserting this into (30b) results in

 ˆpθ(xt∣y1:t−1) =∫\fθ(xt∣xt−1)\Np∑i=1\wit−1δxit−1(xt−1)\mydxt−1 =\Np∑i=1\wit−1\fθ(xt∣xit−1). (32)

That is, we obtain a mixture distribution approximating , where we have one mixture component for each of the particles at time . Furthermore, inserting (32) into (30a) results in the following approximation of the filtering

 pθ(xt∣y1:t)≈\gθ(yt∣xt)pθ(yt∣y1:t−1)\Np∑i=1\wit−1\fθ(xt∣xit−1). (33)

The task is now to approximate (33) using importance sampling. Inspired by the structure of (33) we choose a proposal density (again denoted by ) of the same form, namely as a mixture distribution,

 \proposalSMC(xt∣y1:t)\eqdef\Np∑i=1νit−1\proposalSMC(xt∣xit−1,yt), (34)

where both the mixture components and the mixture weights are design choices constituting parts of the proposal distribution.

To generate a sample from the mixture distribution (34) the following two-step procedure is used; first we randomly select one of the components, and then we generate a sample from that particular component. Note that we will sample particles from the proposal distribution (34). Let us use to denote the index of the mixture component selected for the particle at time . Now, since the probability of selecting component is encoded by its weight , we have that

 \myProbait=j =νjt−1, j =\range1N. (35)

Subsequently, we can generate a sample from the selected component according to , where . By construction is now a sample from the proposal density (34). The particle is referred to as the ancestor particle of , since is generated conditionally on . This also explains why the index  is commonly referred to as the ancestor index, since it indexes the ancestor of particle  at time .

In practice we sample the ancestor indices according to (35) in one go. This results in a new set of particles that are subsequently used to propagate the particles to time . This procedure, which (randomly) generates by selection (sampling with replacement) from among according to some weights, is commonly referred to as resampling.

The next step is to assign importance weights to the new particles accounting for the discrepancy between the target distribution and the proposal distribution . As before, the weights are computed as the ratio between the (unnormalised) target and the proposal . Direct use of (33) and (34) results in

 \uwit=\gθ(yt∣xit)∑\Npj=1\wjt−1\fθ(xit∣xjt−1)∑\Npj=1νjt−1\proposalSMC(xit∣xjt−1,yt). (36)

By evaluating for and normalising the weights, we obtain a new set of weighted particles , constituting an empirical approximation of . This completes the algorithm, since these weighted particles in turn can be used to approximate the filtering at time , then at time and so on.

A problem with the algorithm presented above is that the weight calculation in (36) has a computational complexity of for each particle, rendering an overall computational complexity of , since the weights need to be computed for all particles. A pragmatic solution to this problem is to use the freedom available in the proposal density and select it according to . That is, we select ancestor particles with probabilities given by their importance weights and sample new particles by simulating the system dynamics from time  to . Inserting this into (36) results in the simple expression , which brings the overall computational complexity down to . The resulting algorithm is referred to as the bootstrap particle filter and it is summarised in Algorithm 1.

The bootstrap was the first working particle filter, an early and influential derivation is provided by Gordon et al. (1993). It is arguably the simplest possible implementation of , but nevertheless, it incorporates the essential methodological ideas that underpin the general framework. Importance sampling (propagation and weighting in Algorithm 1 above) and resampling

are used to sequentially approximate a sequence of probability distributions of interest; here

.

Selecting the dynamics as proposal distribution, as in the bootstrap particle filter, is appealing due to the simplicity of the resulting algorithm. However, this choice is unfortunately also suboptimal, since the current measurement is not taken into account when simulating the particles from the proposal distribution. A better strategy of reducing the computational complexity of the weight computation from to is to target the joint distribution of with an importance sampler, instead of directly targeting the marginal distribution of as was done above. Indeed, by explicitly introducing the ancestor indices as auxiliary variables in the importance sampler, we obtain the weight expression

 \uwit=\waitt−1\gθ(yt∣xit)\fθ(xit∣xaitt−1)νaitt−1\proposalSMC(xit∣xaitt−1,yt), (37)

as a more practical alternative to (36). With this approach we have the possibility of freely selecting the mixture weights and mixture components of the proposal, while still enjoying an overall linear computational complexity. The resulting algorithm is referred to as the auxiliary particle filter (). Rather than providing the details of the derivation we simply refer to the original paper by Pitt and Shephard (1999) or our complete derivation in Schön and Lindsten (2015).

### 5.2 Some useful properties of the

As any Monte Carlo algorithm, the can be interpreted as a random number generator. Indeed, the particles and the ancestor indices used within the algorithm are random variables, and executing the algorithm corresponds to simulating a realisation of these variables. It can be useful, both for understanding the properties of the and for developing more advanced algorithms around , to make this more explicit. Let

 xt ≜\crangex1tx\Npt, and at ≜\crangea1ta\Npt, (38)

refer to all the particles and ancestor indices, respectively, generated by the at time . The in Algorithm 1 then generates a single realisation of a collection of random variables . Furthermore, since we know how these variables are generated, we can directly write down their joint 111to a natural product of Lebesgue and counting measure. as,

 ψθ(x1:\T,a2:\T∣y1:\T)≜\Np∏i=1μθ(xi1)\T∏t=2⎧⎨⎩\Np∏i=1\waittfθ(xit∣xaitt−1)⎫⎬⎭. (39)

Naturally, any estimator derived from the will also be a random variable. From (39) we note that the distribution of this random variable will depend on the number of particles , and convergence of the algorithm can be identified with convergence, in some sense, of this random variable. Specifically, let be some test function of interest. The posterior expectation , can be estimated by the PF by computing (, (16)),

 ˆφNt\eqdefN∑i=1witφ(xit). (40)

There is a solid theoretical foundation for , , investigating the convergence of (40) to the true expectation as and establishing non-asymptotic bounds on the approximation error. The (types of) existing theoretical results are too numerous to be mentioned here, and we refer to the book by Del Moral (2004)

for a comprehensive treatment. However, to give a flavour of the type of results that can be obtained we state a central limit theorem (CLT) for the estimator (

40). Under weak regularity assumptions it holds that (Del Moral and Miclo, 2000; Del Moral, 2004; Chopin, 2004),

 √N(ˆφNt−\CExpbθφ(xt)y1:t)\ConvDist\N(0,σ2t(φ)), (41)

as where denotes convergence in distribution. The asymptotic estimator variance depends on the test function , the specific PF implementation that is used and, importantly, the properties of the state space model (an explicit expression for is given by Doucet and Johansen (2011)).

The CLT in (41) is reassuring since it reveals that the estimator converges at a rate , which is the same rate as for independent and identically distributed () Monte Carlo estimators. An interesting question to ask, however, is how the asymptotic variance depends on . In particular, recall from (33) that we use the approximation of the filtering distribution at time , in order to construct the target distribution, which in turn is approximated by the particles at time . This “approximation of an approximation” interpretation of the PF may, rightfully, lead to doubts about the stability of the approximation. In other words, will the asymptotic variance grow exponentially with ?

Fortunately, in many realistic scenarios, the answer to this question is no. The key to this result is that the model exhibits some type of forgetting, essentially meaning that the dependence between states and diminishes (fast enough) as gets large. If this is the case, we can bound for some constant which is independent of , ensuring the stability of the PF approximation. We refer to Del Moral and Guionnet (2001); Chopin (2004) for more precise results in this direction.

In analogy with the Kalman filter, the PF does not only compute the filtering distribution, but it also provides (an approximation of) the likelihood , which is central to the system identification problem. For the bootstrap PF in Algorithm 1, this is given by,

 ˆpθ(y1:t)=t∏s=1⎧⎨⎩1\Np\Np∑i=1\uwis⎫⎬⎭. (42)

Note that the approximation is computed using the unnormalised importance weights . The expression (42) can be understood by considering the factorisation (4) and noting that the one-step predictive likelihood, by (7), can be approximated by,

 ˆpθ(ys∣y1:s−1) =∫gθ(ys∣xs)ˆpθ(xs∣y1:s−1)\mydxs =1NN∑i=1gθ(ys∣xis)=1NN∑i=1\uwis,

where are simulated from the bootstrap proposal given by