Skip to content

Commit

Permalink
actually added bootstrap docs
Browse files Browse the repository at this point in the history
  • Loading branch information
zsunberg committed Jan 4, 2025
1 parent ea566b7 commit 3030505
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions docs/src/bootstrap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Bootstrap Filter

The [`BootstrapFilter`](@ref) is the simplest filter provided by the library and should be the starting point for most tasks.

## Quick Start

With a POMDPs.jl model, setup looks like this:
```jldoctest intro; output=false, filter=r"BasicParticleFilter.*" => s"BasicParticleFilter"
using ParticleFilters, POMDPModels
pomdp = TigerPOMDP()
pf = BootstrapFilter(pomdp, 10)
# output
BasicParticleFilter()
```

Without POMDPs.jl, setup looks like this:
```jldoctest intro; output=false, filter=r"BasicParticleFilter.*" => s"BasicParticleFilter"
using ParticleFilters
using Distributions: Normal
dynamics(x, u, rng) = x + u + randn(rng)
y_likelihood(x_previous, u, x, y) = pdf(Normal(), y - x)
pf = BootstrapFilter(dynamics, y_likelihood, 10)
# output
BasicParticleFilter()
```

Once the filter has been created the [`update`](@ref) function can be used to perform a particle filter update.
```jldoctest intro; output=false, filter=r"WeightedParticleBelief.*" => s"WeightedParticleBelief"
b = ParticleCollection([1.0, 2.0, 3.0, 4.0])
u = 1.0
y = 3.0
b_new = update(pf, b, u, y)
# output
WeightedParticleBelief()
```

## More on the Bootstrap Filter

The [`BootstrapFilter`](@ref) is designed to be a sensible default choice for starting with particle filtering. The basic bootstrap filter approach was first described in "Novel approach to nonlinear / non-Gaussian Bayesian state estimation" by Gordon, Salmond, and Smith.
The version in this package first checks whether the normalized [effective sample size](@ref effective_sample_size) of the particle belief is above a threshold (the `resample_threshold` argument). If it is below the threshold, the belief is resampled using [`low_variance_sample`](@ref). The particles are then propagated through the dynamics model and weighted by the likelihood of the observation.

The `BootstrapFilter` offers a modest level of customization. The most common need for customization is recovering from particle depletion. For this case, use the `postprocess` keyword argument to specify a function that can be used to check for depletion and recover. See the [Handling Particle Depletion](@ref) section for more information about this task. If more customization is needed, users should use the [`BasicParticleFilter`](@ref).

```@docs
BootstrapFilter
```

0 comments on commit 3030505

Please sign in to comment.