-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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?
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} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
src/resamplers.jl
Outdated
) | ||
return reset_weights!(state, idxs, filter) |
There was a problem hiding this comment.
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.
src/algorithms/apf.jl
Outdated
predicted = map( | ||
x -> SSMProblems.simulate(rng, model.dyn, step, x; kwargs...), | ||
states.filtered.particles, | ||
) |
There was a problem hiding this comment.
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
?
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
I can add a comparison, this is not really ready for prime time, just seeing if more general filters would fit into the API |
bd2e22f
to
0fadd2b
Compare
0fadd2b
to
c791095
Compare
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
inpredict
.