Generalized filtering is a generic Bayesian filtering scheme for nonlinear state-space models. It is based on a variational principle of least action, formulated in generalized coordinates of motion. 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, dynamic expectation maximization and generalized predictive coding. == Definition == Definition: Generalized filtering rests on the tuple ( Ω , U , X , S , p , q ) {\displaystyle (\Omega ,U,X,S,p,q)} : A sample space Ω {\displaystyle \Omega } from which random fluctuations ω ∈ Ω {\displaystyle \omega \in \Omega } are drawn Control states U ∈ R {\displaystyle U\in \mathbb {R} } – that act as external causes, input or forcing terms Hidden states X : X × U × Ω → R {\displaystyle X:X\times U\times \Omega \to \mathbb {R} } – that cause sensory states and depend on control states Sensor states S : X × U × Ω → R {\displaystyle S:X\times U\times \Omega \to \mathbb {R} } – a probabilistic mapping from hidden and control states Generative density p ( s ~ , x ~ , u ~ ∣ m ) {\displaystyle p({\tilde {s}},{\tilde {x}},{\tilde {u}}\mid m)} – over sensory, hidden and control states under a generative model m {\displaystyle m} Variational density q ( x ~ , u ~ ∣ μ ~ ) {\displaystyle q({\tilde {x}},{\tilde {u}}\mid {\tilde {\mu }})} – over hidden and control states with mean μ ~ ∈ R {\displaystyle {\tilde {\mu }}\in \mathbb {R} } Here ~ denotes a variable in generalized coordinates of motion: u ~ = [ u , u ′ , u ″ , … ] T {\displaystyle {\tilde {u}}=[u,u',u'',\ldots ]^{T}} === Generalized filtering === 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 p ( s ~ ( t ) | m ) {\displaystyle p({\tilde {s}}(t)\vert m)} 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. Given the following definitions: μ ~ ( t ) = a r g m i n μ ~ { F ( s ~ ( t ) , μ ~ ) } {\displaystyle {\tilde {\mu }}(t)={\underset {\tilde {\mu }}{\operatorname {arg\,min} }}\{F({\tilde {s}}(t),{\tilde {\mu }})\}} G ( s ~ , x ~ , u ~ ) = − ln p ( s ~ , x ~ , u ~ | m ) {\displaystyle G({\tilde {s}},{\tilde {x}},{\tilde {u}})=-\ln p({\tilde {s}},{\tilde {x}},{\tilde {u}}\vert m)} Denote the Shannon entropy of the density q {\displaystyle q} by H [ q ] = E q [ − log ( q ) ] {\displaystyle H[q]=E_{q}[-\log(q)]} . We can then write the variational free energy in two ways: F ( s ~ , μ ~ ) = E q [ G ( s ~ , x ~ , u ~ ) ] − H [ q ( x ~ , u ~ | μ ~ ) ] = − ln p ( s ~ | m ) + D K L [ q ( x ~ , u ~ | μ ~ ) | | p ( x ~ , u ~ | s ~ , m ) ] {\displaystyle F({\tilde {s}},{\tilde {\mu }})=E_{q}[G({\tilde {s}},{\tilde {x}},{\tilde {u}})]-H[q({\tilde {x}},{\tilde {u}}\vert {\tilde {\mu }})]=-\ln p({\tilde {s}}\vert m)+D_{KL}[q({\tilde {x}},{\tilde {u}}\vert {\tilde {\mu }})\vert \vert p({\tilde {x}},{\tilde {u}}\vert {\tilde {s}},m)]} 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). Under the Laplace assumption q ( x ~ , u ~ ∣ μ ~ ) = N ( μ ~ , C ) {\displaystyle q({\tilde {x}},{\tilde {u}}\mid {\tilde {\mu }})={\mathcal {N}}({\tilde {\mu }},C)} the variational density is Gaussian and the precision that minimizes free energy is C − 1 = Π = ∂ μ ~ μ ~ G ( μ ~ ) {\displaystyle C^{-1}=\Pi =\partial _{{\tilde {\mu }}{\tilde {\mu }}}G({\tilde {\mu }})} . This means that free-energy can be expressed in terms of the variational mean (omitting constants): F = G ( μ ~ ) + 1 2 ln | ∂ μ ~ μ ~ G ( μ ~ ) | {\displaystyle F=G({\tilde {\mu }})+\textstyle {1 \over 2}\ln \vert \partial _{{\tilde {\mu }}{\tilde {\mu }}}G({\tilde {\mu }})\vert } The variational means that minimize the (path integral) of free energy can now be recovered by solving the generalized filter: μ ~ ˙ = D μ ~ − ∂ μ ~ F ( s ~ , μ ~ ) {\displaystyle {\dot {\tilde {\mu }}}=D{\tilde {\mu }}-\partial _{\tilde {\mu }}F({\tilde {s}},{\tilde {\mu }})} where D {\displaystyle D} is a block matrix derivative operator of identify matrices such that D u ~ = [ u ′ , u ″ , … ] T {\displaystyle D{\tilde {u}}=[u',u'',\ldots ]^{T}} === Variational basis === Generalized filtering is based on the following lemma: The self-consistent solution to μ ~ ˙ = D μ ~ − ∂ μ ~ F ( s , μ ~ ) {\displaystyle {\dot {\tilde {\mu }}}=D{\tilde {\mu }}-\partial _{\tilde {\mu }}F(s,{\tilde {\mu }})} satisfies the variational principle of stationary action, where action is the path integral of variational free energy S = ∫ d t F ( s ~ ( t ) , μ ~ ( t ) ) {\displaystyle S=\int dt\,F({\tilde {s}}(t),{\tilde {\mu }}(t))} Proof: self-consistency requires the motion of the mean to be the mean of the motion and (by the fundamental lemma of variational calculus) μ ~ ˙ = D μ ~ ⇔ ∂ μ ~ F ( s ~ , μ ~ ) = 0 ⇔ δ μ ~ S = 0 {\displaystyle {\dot {\tilde {\mu }}}=D{\tilde {\mu }}\Leftrightarrow \partial _{\tilde {\mu }}F({\tilde {s}},{\tilde {\mu }})=0\Leftrightarrow \delta _{\tilde {\mu }}S=0} 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: μ ~ ˙ − D μ ~ = − ∂ μ ~ F ( s , μ ~ ) {\displaystyle {\dot {\tilde {\mu }}}-D{\tilde {\mu }}=-\partial _{\tilde {\mu }}F(s,{\tilde {\mu }})} , where the frame itself minimizes variational free energy. For a related example in statistical physics, see Kerr and Graham 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 over intervals Δ t {\displaystyle \Delta t} to recover discrete updates Δ μ ~ = ( exp ( Δ t ⋅ J ) − I ) J − 1 μ ~ ˙ J = ∂ μ ~ μ ~ ˙ = D − ∂ μ ~ μ ~ F ( s ~ , μ ~ ) {\displaystyle {\begin{aligned}\Delta {\tilde {\mu }}&=(\exp(\Delta t\cdot J)-I)J^{-1}{\dot {\tilde {\mu }}}\\J&=\partial _{\tilde {\mu }}{\dot {\tilde {\mu }}}=D-\partial _{{\tilde {\mu }}{\tilde {\mu }}}F({\tilde {s}},{\tilde {\mu }})\end{aligned}}} This updates the means of hidden variables at each interval (usually the interval between observations). == Generative (state-space) models in generalized coordinates == Usually, the generative density or model is specified in terms of a nonlinear input-state-output model with continuous nonlinear functions: s = g ( x , u ) + ω s x ˙ = f ( x , u ) + ω x {\displaystyle {\begin{aligned}s&=g(x,u)+\omega _{s}\\{\dot {x}}&=f(x,u)+\omega _{x}\end{aligned}}} The corresponding generalized model (under local linearity assumptions) obtains the from the chain rule s ~ = g ~ ( x ~ , u ~ ) + ω ~ s s = g ( x , u ) + ω s s ′ = ∂ x g ⋅ x ′ + ∂ u g ⋅ u ′ + ω s ′ s ″ = ∂ x g ⋅ x ″ + ∂ u g ⋅ u ″ + ω s ″ ⋮ x ~ ˙ = f ~ ( x ~ , u ~ ) + ω ~ x x ˙ = f ( x , u ) + ω x x ˙ ′ = ∂ x f ⋅ x ′ + ∂ u f ⋅ u ′ + ω x ′ x ˙ ″ = ∂ x f ⋅ x ″ + ∂ u f ⋅ u ″ + ω x ″ ⋮ {\displaystyle {\begin{aligned}{\tilde {s}}&={\tilde {g}}({\tilde {x}},{\tilde {u}})+{\tilde {\omega }}_{s}\\\\s&=g(x,u)+\omega _{s}\\s'&=\partial _{x}g\cdot x'+\partial _{u}g\cdot u'+\omega '_{s}\\s''&=\partial _{x}g\cdot x''+\partial _{u}g\cdot u''+\omega ''_{s}\\&\vdots \\\end{aligned}}\qquad {\begin{aligned}{\dot {\tilde {x}}}&={\tilde {f}}({\tilde {x}},{\tilde {u}})+{\tilde {\omega }}_{x}\\\\{\dot {x}}&=f(x,u)+\omega _{x}\\{\dot {x}}'&=\partial _{x}f\cdot x'+\partial _{u}f\cdot u'+\omega '_{x}\\{\dot {x}}''&=\partial _{x}f\cdot x''+\partial _{u}f\cdot u''+\omega ''_{x}\\&\vdots \end{aligned}}} Gaussian assumptions about the random fluctuations ω {\displaystyle \omega } then prescribe the likelihood and empirical priors on the motion of hidden states p ( s ~ , x ~ , u ~ | m ) = p ( s ~ | x ~ , u ~ , m ) p ( D x ~ | x , u ~ , m ) p ( x | m ) p ( u ~ | m ) p ( s ~ | x ~ , u ~ , m ) = N ( g ~ ( x ~ , u ~ ) , Σ ~ ( x ~ , u ~ ) s ) p ( D x ~ | x , u ~ , m ) = N ( f ~ ( x ~ , u ~ ) , Σ ~ ( x ~ , u ~ ) x ) {\displayst
Read more →