GeneralisedFilters
Installation
In the julia REPL:
] add GeneralisedFiltersDocumentation
GeneralisedFilters provides implementations of various filtering and smoothing algorithms for state-space models (SSMs). The goal of the package is to provide a modular and extensible framework for implementing advanced algorithms including Rao-Blackwellised particle filters, two-filter smoothers, and particle Gibbs/conditional SMC. Performance is a primary focus of this work, with type stability, GPU-acceleration, and efficient history storage being key design goals.
Interface
GeneralisedFilters.AncestorCallback — TypeAncestorCallbackA callback for sparse ancestry storage, which preallocates and returns a populated ParticleTree object.
GeneralisedFilters.BackwardInformationPredictor — TypeBackwardInformationPredictorAn algorithm to recursively compute the predictive likelihood p(y{t:T} | xt) of a linear Gaussian state space model in information form.
This implementation is based on https://arxiv.org/pdf/1505.06357
GeneralisedFilters.DenseAncestorCallback — TypeDenseAncestorCallbackA callback for dense ancestry storage, which fills a DenseParticleContainer.
GeneralisedFilters.HierarchicalState — TypeA container for a sampled state from a hierarchical SSM, with separation between the outer and inner dimensions. Note this differs from a RBState in the the inner state is a sample rather than a conditional distribution.
GeneralisedFilters.Particle — TypeParticleA container representing a single particle in a particle filter distribution, composed of a weighted sampled (stored as a log weight) and its ancestor index.
GeneralisedFilters.ParticleDistribution — TypeParticleDistributionA container for particle filters which composes a collection of weighted particles (with their ancestories) into a distibution-like object.
Fields
particles::VT: Vector of weighted particlesll_baseline::WT: Baseline for computing log-likelihood increment. A scalar that caches the unnormalized logsumexp of weights before update (for standard PF/guided filters) or a modified value that includes APF first-stage correction (for auxiliary PF).
GeneralisedFilters.ParticleTree — TypeParticleTreeA sparse container for particle ancestry, which tracks the lineage of the filtered draws.
Reference
Jacob, P., Murray L., & Rubenthaler S. (2015). Path storage in the particle filter doi:10.1007/s11222-013-9445-x
GeneralisedFilters.RBState — TypeRBStateA container representing a single state with a Rao-Blackwellised component. This differs from a HierarchicalState which contains a sample of the conditionally analytical state rather than the distribution itself.
Fields
x::XT: The sampled state componentz::ZT: The Rao-Blackwellised distribution component
GeneralisedFilters.ResamplerCallback — TypeResamplerCallbackA callback which follows the resampling indices over the filtering algorithm. This is more of a debug tool and visualizer for various resapmling algorithms.
GeneralisedFilters.backward_initialise — Methodbackward_initialise(rng, obs, algo, iter, y; kwargs...)Initialise a backward predictor at time T with observation y, forming the likelihood p(yT | xT).
GeneralisedFilters.backward_predict — Methodbackward_predict(rng, dyn, algo, iter, state; prev_outer=nothing, next_outer=nothing, kwargs...)Perform a backward prediction step to compute p(y{t+1:T} | xt) from p(y{t:T} | x{t+1}).
GeneralisedFilters.backward_update — Methodbackward_update(obs, algo, iter, state, y; kwargs...)Incorporate an observation y at time t to compute p(y{t:T} | xt) from p(y{t+1:T} | xt).
GeneralisedFilters.compute_marginal_predictive_likelihood — Methodcompute_marginal_predictive_likelihood(forward_dist, backward_dist)Compute the marginal predictive likelihood p(y{t:T} | y{1:t-1}) given a one-step predicted filtering distribution p(x{t+1} | y{1:t}) and a backward predictive likelihood p(y{t+1:T} | x{t+1}).
This Gaussian implementation is based on Lemma 1 of https://arxiv.org/pdf/1505.06357
GeneralisedFilters.initialise — Functioninitialise([rng,] model, algo; kwargs...)Propose an initial state distribution.
GeneralisedFilters.marginalise! — Methodmarginalise!(state::ParticleDistribution)Compute the log-likelihood increment and normalize particle weights. This function:
- Computes LSE of current (post-observation) log-weights
- Calculates llincrement = LSEafter - ll_baseline
- Normalizes weights by subtracting LSE_after
- Resets ll_baseline to 0.0
The llbaseline field handles both standard particle filter and auxiliary particle filter cases through a single-scalar caching mechanism. For standard PF, llbaseline equals the LSE before adding observation weights. For APF with resampling, it includes first-stage correction terms computed during the APF resampling step.
GeneralisedFilters.predict — Functionpredict([rng,] model, algo, iter, filtered; kwargs...)Propagate the filtered distribution forward in time.
GeneralisedFilters.step — Functionstep([rng,] model, algo, iter, state, observation; kwargs...)Perform a combined predict and update call of the filtering on the state.
GeneralisedFilters.update — Functionupdate(model, algo, iter, proposed, observation; kwargs...)Update beliefs on the propagated distribution given an observation.
GeneralisedFilters.will_resample — Methodwill_resample(resampler::AbstractResampler, state::ParticleDistribution)Determine whether a resampler will trigger resampling given the current particle state. For uncondition resamplers, always returns true. For conditional resamplers (e.g., ESSResampler), checks the resampling condition.