Generalized filtering is a generic Bayesian filtering scheme for nonlinear state-space models.[1] It is based on a variational principle of least action, formulated in generalized coordinates of motion.[2] Note that "generalized coordinates of motion" are related to—but distinct from—generalized coordinates as used in (multibody) dynamical systems analysis. Generalized filtering furnishes posterior densities over hidden states (and parameters) generating observed data using a generalized gradient descent on variational free energy, under the Laplace assumption. Unlike classical (e.g. Kalman-Bucy or particle) filtering, generalized filtering eschews Markovian assumptions about random fluctuations. Furthermore, it operates online, assimilating data to approximate the posterior density over unknown quantities, without the need for a backward pass. Special cases include variational filtering,[3] dynamic expectation maximization[4] and generalized predictive coding.
Definition: Generalized filtering rests on the tuple :
- A sample space from which random fluctuations are drawn
- Control states – that act as external causes, input or forcing terms
- Hidden states – that cause sensory states and depend on control states
- Sensor states – a probabilistic mapping from hidden and control states
- Generative density – over sensory, hidden and control states under a generative model
- Variational density – over hidden and control states with mean
Here ~ denotes a variable in generalized coordinates of motion:
Generalized filtering
[edit]
The objective is to approximate the posterior density over hidden and control states, given sensor states and a generative model – and estimate the (path integral of) model evidence to compare different models. This generally involves an intractable marginalization over hidden states, so model evidence (or marginal likelihood) is replaced with a variational free energy bound.[5] Given the following definitions:
Denote the Shannon entropy of the density by . We can then write the variational free energy in two ways:
The second equality shows that minimizing variational free energy (i) minimizes the Kullback-Leibler divergence between the variational and true posterior density and (ii) renders the variational free energy (a bound approximation to) the negative log evidence (because the divergence can never be less than zero).[6] Under the Laplace assumption the variational density is Gaussian and the precision that minimizes free energy is . This means that free-energy can be expressed in terms of the variational mean [7] (omitting constants):
The variational means that minimize the (path integral) of free energy can now be recovered by solving the generalized filter:
where is a block matrix derivative operator of identify matrices such that
Generalized filtering is based on the following lemma: The self-consistent solution to satisfies the variational principle of stationary action, where action is the path integral of variational free energy
Proof: self-consistency requires the motion of the mean to be the mean of the motion and (by the fundamental lemma of variational calculus)
Put simply, small perturbations to the path of the mean do not change variational free energy and it has the least action of all possible (local) paths.
Remarks: Heuristically, generalized filtering performs a gradient descent on variational free energy in a moving frame of reference: , where the frame itself minimizes variational free energy. For a related example in statistical physics, see Kerr and Graham [8] who use ensemble dynamics in generalized coordinates to provide a generalized phase-space version of Langevin and associated Fokker-Planck equations.
In practice, generalized filtering uses local linearization[9] over intervals to recover discrete updates
This updates the means of hidden variables at each interval (usually the interval between observations).
Generative (state-space) models in generalized coordinates
[edit]
Usually, the generative density or model is specified in terms of a nonlinear input-state-output model with continuous nonlinear functions:
The corresponding generalized model (under local linearity assumptions) obtains the from the chain rule
Gaussian assumptions about the random fluctuations then prescribe the likelihood and empirical priors on the motion of hidden states
The covariances factorize into a covariance among variables and correlations among generalized fluctuations that encodes their autocorrelation:
Here, is the second derivative of the autocorrelation function evaluated at zero. This is a ubiquitous measure of roughness in the theory of stochastic processes.[10] Crucially, the precision (inverse variance) of high order derivatives fall to zero fairly quickly, which means it is only necessary to model relatively low order generalized motion (usually between two and eight) for any given or parameterized autocorrelation function.
Filtering discrete time series
[edit]
When time series are observed as a discrete sequence of observations, the implicit sampling is treated as part of the generative process, where (using Taylor's theorem)
In principle, the entire sequence could be used to estimate hidden variables at each point in time. However, the precision of samples in the past and future falls quickly and can be ignored. This allows the scheme to assimilate data online, using local observations around each time point (typically between two and eight).
Generalized filtering and model parameters
[edit]
For any slowly varying model parameters of the equations of motion or precision generalized filtering takes the following form (where corresponds to the variational mean of the parameters)
Here, the solution minimizes variational free energy, when the motion of the mean is small. This can be seen by noting . It is straightforward to show that this solution corresponds to a classical Newton update.[11]
Relationship to Bayesian filtering and predictive coding
[edit]
Generalized filtering and Kalman filtering
[edit]
Classical filtering under Markovian or Wiener assumptions is equivalent to assuming the precision of the motion of random fluctuations is zero. In this limiting case, one only has to consider the states and their first derivative . This means generalized filtering takes the form of a Kalman-Bucy filter, with prediction and correction terms:
Substituting this first-order filtering into the discrete update scheme above gives the equivalent of (extended) Kalman filtering.[12]
Generalized filtering and particle filtering
[edit]
Particle filtering is a sampling-based scheme that relaxes assumptions about the form of the variational or approximate posterior density. The corresponding generalized filtering scheme is called variational filtering.[3] In variational filtering, an ensemble of particles diffuse over the free energy landscape in a frame of reference that moves with the expected (generalized) motion of the ensemble. This provides a relatively simple scheme that eschews Gaussian (unimodal) assumptions. Unlike particle filtering it does not require proposal densities—or the elimination or creation of particles.
Generalized filtering and variational Bayes
[edit]
Variational Bayes rests on a mean field partition of the variational density:
This partition induces a variational update or step for each marginal density—that is usually solved analytically using conjugate priors. In generalized filtering, this leads to dynamic expectation maximisation.[4] that comprises a D-step that optimizes the sufficient statistics of unknown states, an E-step for parameters and an M-step for precisions.
Generalized filtering and predictive coding
[edit]
Generalized filtering is usually used to invert hierarchical models of the following form
The ensuing generalized gradient descent on free energy can then be expressed compactly in terms of prediction errors, where (omitting high order terms):
Here, is the precision of random fluctuations at the i-th level. This is known as generalized predictive coding [11], with linear predictive coding as a special case.
Generalized filtering has been primarily applied to biological timeseries—in particular functional magnetic resonance imaging and electrophysiological data. This is usually in the context of dynamic causal modelling to make inferences about the underlying architectures of (neuronal) systems generating data.[13] It is also used to simulate inference in terms of generalized (hierarchical) predictive coding in the brain.[14]
- ^ K Friston, K Stephan, B Li, and J. Daunizeau, "Generalised Filtering," Mathematical Problems in Engineering, vol. vol., 2010, p. 621670, 2010.
- ^ B Balaji and K Friston, "Bayesian state estimation using generalized coordinates," Proc. SPIE, p. 80501Y, 2011
- ^ a b K J Friston, "Variational filtering," Neuroimage, vol. 41, no. 3, pp. 747-66, 2008.
- ^ a b K J Friston, N Trujillo-Barreto, and J Daunizeau, "DEM: A variational treatment of dynamic systems," Neuroimage, vol. 41, no. 3, pp. 849-85, 2008
- ^ R P Feynman, Statistical mechanics. Reading MA: Benjamin, 1972
- ^ M J Beal, "Variational Algorithms for Approximate Bayesian Inference," PhD. Thesis, University College London, 2003.
- ^ K Friston, J Mattout, N Trujillo-Barreto, J Ashburner, and W Penny, "Variational free energy and the Laplace approximation," NeuroImage, vol. 34, no. 1, pp. 220-34, 2007
- ^ W C Kerr and A J Graham, "Generalised phase space version of Langevin equations and associated Fokker-Planck equations," Eur. Phys. J. B., vol. 15, pp. 305-11, 2000.
- ^ T Ozaki, "A bridge between nonlinear time-series models and nonlinear stochastic dynamical systems: A local linearization approach," Statistica Sin., vol. 2, pp. 113-135, 1992
- ^ D R Cox and H D Miller, The theory of stochastic processes. London: Methuen, 1965.
- ^ K Friston, K Stephan, B Li, and J. Daunizeau, "Generalised Filtering," Mathematical Problems in Engineering, vol. vol., 2010, p. 621670, 2010.
- ^ K J Friston, N Trujillo-Barreto, and J Daunizeau, "DEM: A variational treatment of dynamic systems," Neuroimage, vol. 41, no. 3, pp. 849-85, 2008
- ^ J Daunizeau, O David, and K E Stephan, "Dynamic causal modelling: a critical review of the biophysical and statistical foundations Archived 2012-12-07 at the Wayback Machine," Neuroimage, vol. 58, no. 2, pp. 312-22, 2011
- ^ K Friston, "Hierarchical models in the brain," PLoS Comput. Biol., vol. 4, no. 11, p. e1000211, 2008.
- software demonstrations and applications are available as academic freeware (as Matlab code) in the DEM toolbox of SPM
- papers collection of technical and application papers