Beliefs
Types
ParticleFilters.jl provides two types of particle beliefs. ParticleCollection
is little more than a vector of unweighted particles. WeightedParticleBelief
allows for different weights for each of the particles.
Both are subtypes of AbstractParticleBelief
and implement the same particle belief interface. For probability mass calculations (the pdf
function), a dictionary containing the normalized sum of weights for all identical particles is created on the first call and cached for efficient future querying.
ParticleFilters.ParticleCollection
— TypeParticleCollection{S}
Unweighted particle belief consisting of equally important particles of type S
.
ParticleFilters.WeightedParticleBelief
— TypeWeightedParticleBelief{S}
Weighted particle belief consisting of particles of type S
and their associated weights.
Interface
Standard POMDPs.jl Distribution Interface
The following functions from the POMDPs.jl distributions interface provide basic ways of interacting with particle beliefs as distributions (click on each for documentation):
Particle Interface
These functions provide access to the particles and weights in the beliefs (click on each for docstrings):
Interface Docstrings
Base.rand
— Functionrand(rng::AbstractRNG, d::Any)
Return a random element from distribution or space d
.
If d
is a state or transition distribution, the sample will be a state; if d
is an action distribution, the sample will be an action or if d
is an observation distribution, the sample will be an observation.
Distributions.pdf
— Functionpdf(d::Any, x::Any)
Evaluate the probability density of distribution d
at sample x
.
Distributions.support
— Functionsupport(d::Any)
Return an iterable object containing the possible values that can be sampled from distribution d. Values with zero probability may be skipped.
StatsBase.mode
— Functionmode(d::Any)
Return the most likely value in a distribution d.
Statistics.mean
— Functionmean(d::Any)
Return the mean of a distribution d.
ParticleFilters.n_particles
— Functionn_particles(b::AbstractParticleBelief)
Return the number of particles.
ParticleFilters.particles
— Functionparticles(b::AbstractParticleBelief)
Return an iterator over the particles.
ParticleFilters.weights
— Functionweights(b::AbstractParticleBelief)
Return an iterator over the weights.
ParticleFilters.weighted_particles
— Functionweighted_particles(b::AbstractParticleBelief)
Return an iterator over particle-weight pairs.
ParticleFilters.weight_sum
— Functionweight_sum(b::AbstractParticleBelief)
Return the sum of the weights of the particle collection.
ParticleFilters.weight
— Functionweight(b::AbstractParticleBelief, i)
Return the weight for particle i.
ParticleFilters.particle
— Functionparticle(b::AbstractParticleBelief, i)
Return particle i.
ParticleFilters.probdict
— Functionprobdict(b::AbstractParticleBelief)
Return a dictionary mapping states to probabilities.
The probability is the normalized sum of the weights for all matching particles.
For ParticleCollection and WeightedParticleBelief, the result is cached for efficiency so the calculation is only performed the first time this is called. There is a default implementation for all AbstractParticleBeliefs, but it is inefficient (it creates a new dictionary every time). New AbstractParticleBelief implementations should provide an efficient implementation.