Basic Particle Filter

Update Steps

The basic particle filtering step in ParticleFilters.jl is implemented in the update function, and consists of three steps:

  1. Prediction (or propagation) - each state particle is simulated forward one step in time
  2. Reweighting - an explicit measurement (observation) model is used to calculate a new weight
  3. Resampling - a new collection of state particles is generated with particle frequencies proportional to the new weights

This is an example of sequential importance resampling using the state transition distribution as the proposal distribution, and the BootstrapFilter constructor can be used to construct such a filter with a model that controls the prediction and reweighting steps, and a number of particles to create in the resampling phase.

A more flexible structure for building a particle filter is the BasicParticleFilter. It contains three models, one for each step:

  1. The predict_model controls prediction through predict!
  2. The reweight_model controls reweighting through reweight!
  3. The resampler controls resampling through resample

ParticleFilters.jl contains implementations of these components that can be mixed and matched. In many cases the prediction and reweighting steps use the same model, for example a ParticleFilterModel or a POMDP.

To carry out the steps individually without the need for pre-allocating memory or doing a full update step, the predict, reweight, and resample functions are provided.

Docstrings

ParticleFilters.BootstrapFilterFunction
BootstrapFilter(model, n, [rng])

Construct a standard bootstrap particle filter.

The Bootstrap filter was first described in Gordon, N. J., Salmond, D. J., & Smith, A. F. M. "Novel approach to nonlinear / non-Gaussian Bayesian state estimation", with the added robustness of the LowVarianceResampler.

Arguments

  • model: a model for the prediction dynamics and likelihood reweighing, for example a POMDP or ParticleFilterModel
  • n::Integer: number of particles
  • rng::AbstractRNG: random number generator

For a more flexible particle filter structure see BasicParticleFilter.

source
ParticleFilters.BasicParticleFilterType
BasicParticleFilter(predict_model, reweight_model, resampler, n_init::Integer, rng::AbstractRNG)
BasicParticleFilter(model, resampler, n_init::Integer, rng::AbstractRNG)

Construct a basic particle filter with three steps: predict, reweight, and resample.

In the second constructor, model is used for both the prediction and reweighting.

source
POMDPs.updateFunction
update(updater::Updater, belief_old, action, observation)

Return a new instance of an updated belief given belief_old and the latest action and observation.

source
ParticleFilters.predict!Function
predict!(pm, m, b, u, rng)
predict!(pm, m, b, u, y, rng)

Fill pm with predicted particles for the next time step.

A method of this function should be implemented by prediction models to be used in a BasicParticleFilter. pm should be a correctly-sized vector created by particle_memory to hold a one-step-propagated particle for each particle in b.

Normally the observation y is not needed, so most prediction models should implement the first version, but the second is available for heuristics that use y.

Arguments

  • pm::Vector: memory for holding the propagated particles; created by particle_memory and resized to n_particles(b).
  • m: prediction model, the "owner" of this function
  • b::ParticleCollection: current belief; each particle in this belief should be propagated one step and inserted into pm.
  • u: control or action
  • rng::AbstractRNG: random number generator; should be used for any randomness in propagation for reproducibility.
  • y: measuerement/observation (usually not needed)
source
ParticleFilters.reweight!Function
reweight!(wm, m, b, a, pm, y)
reweight!(wm, m, b, a, pm, y, rng)

Fill wm likelihood weights for each particle in pm.

A method of this function should be implemented by reweighting models to be used in a BasicParticleFilter. wm should be a correctly-sized vector to hold weights for each particle in pm.

Normally rng is not needed, so most reweighting models should implement the first version, but the second is available for heuristics that use random numbers.

Arguments

  • wm::Vector{Float64}: memory for holding likelihood weights.
  • m: reweighting model, the "owner" of this function
  • b::ParticleCollection: previous belief; pm should contain a propagated particle for each particle in this belief
  • u: control or action
  • pm::Vector: memory for holding current particles; these particle have been propagated by predict!.
  • y: measurement/observation
  • rng::AbstractRNG: random number generator; should be used for any randomness for reproducibility.
source
ParticleFilters.resampleFunction
resample(resampler, bp::AbstractParticleBelief, rng::AbstractRNG)

Sample a new ParticleCollection from bp.

Generic domain-independent resamplers should implement this version.

resample(resampler, bp::WeightedParticleBelief, predict_model, reweight_model, b, a, o, rng)

Sample a new particle collection from bp with additional information from the arguments to the update function.

This version defaults to resample(resampler, bp, rng). Domain-specific resamplers that wish to add noise to particles, etc. should implement this version.

source
ParticleFilters.predictFunction
predict(m, b, u, rng)

Simulate each of the particles in b forward one time step using model m and contol input u returning a vector of states. Calls predict! internally - see that function for documentation.

This function is provided for convenience only. New models should implement predict!.

source
ParticleFilters.reweightFunction
reweight(m, b, u, pm, y)

Return a vector of likelihood weights for each particle in pm given observation y.

pm can be generated with predict(m, b, u, rng).

This function is provided for convenience only - new reweighting models should implement reweight!.

source
ParticleFilters.particle_memoryFunction
particle_memory(m)

Return a suitable container for particles produced by prediction model m.

This should usually be an empty Vector{S} where S is the type of the state for prediction model m. Size does not matter because resize! will be called appropriately within update.

source