Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add auxiliary particle filter #11

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

FredericWantiez
Copy link
Member

@FredericWantiez FredericWantiez commented Oct 20, 2024

Add a draft for an auxiliary particle filter. This is more of a proof of concept as we need to change the filter interface a tiny bit.
Looks like we might need to add some of these:

  • reset_weights(filter::AbstractFilter, ...)
  • update_weights!(filter::AbstractFilter, ...)

As well as passing the observation in predict.

Base automatically changed from ck/generalized-filters to main October 22, 2024 13:42
Copy link
Collaborator

@charlesknipp charlesknipp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really exciting stuff and it seems to fit really nicely into the interface. Have you tried replicating the Nile river type experiments, comparing the ESS between the BF and the APF?

Comment on lines 42 to 122
function update_ref!(
pc::ParticleContainer{T}, ref_state::Union{Nothing,AbstractVector{T}}, step::Integer=0
pc::ParticleContainer{T},
ref_state::Union{Nothing,AbstractVector{T}},
::AbstractFilter,
step::Integer=0,
) where {T}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need the filter passed through this function?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need it here, but we might need to dispatch on the filter type when updating the reference particle. That would be useful for ancestor resampling for example

)
return reset_weights!(state, idxs, filter)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer the reset_weights!(...) paired with logmarginal(...) as is done here. @THargreaves and I had a brief back and forth about this, but we never properly settled that discussion.

Comment on lines 53 to 55
predicted = map(
x -> SSMProblems.simulate(rng, model.dyn, step, x; kwargs...),
states.filtered.particles,
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be a deterministic function of states.filtered.particles?

Comment on lines +93 to +104
function step(
rng::AbstractRNG,
model::AbstractStateSpaceModel,
alg::AuxiliaryParticleFilter,
iter::Integer,
state,
observation;
kwargs...,
)
proposed_state = predict(rng, model, alg, iter, state, observation; kwargs...)
filtered_state, ll = update(model, alg, iter, proposed_state, observation; kwargs...)

return filtered_state, ll
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should work without redefining step, as long as AuxiliaryParticleFilter is a subclass of AbstractFilter

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current api doesn't forward observation to predict. I also tend to agree with #9 and splitting resample and predict.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current api doesn't forward observation to predict. I also tend to agree with #9 and splitting resample and predict.

I wonder if it should. For general proposal distributions other than forward simulation (i.e. bootstrap filter) that would be needed.

Or at least have a subtype for Guided, Independent and Auxiliary filters that has this modified step/predict method.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current api doesn't forward observation to predict

I completely forgot about that. We may need to think about defining some sort of AbstractProposal for more complex transition kernels.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And yeah, I agree we should split up resample and predict

@FredericWantiez
Copy link
Member Author

I can add a comparison, this is not really ready for prime time, just seeing if more general filters would fit into the API

@FredericWantiez FredericWantiez force-pushed the fred/auxiliary-particle-filter branch 2 times, most recently from bd2e22f to 0fadd2b Compare October 27, 2024 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants