Skip to content

Make HierarchicalSSM compatible with the BF #70

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

Merged
merged 1 commit into from
Mar 11, 2025
Merged

Conversation

THargreaves
Copy link
Collaborator

Solves #34.

A middle-ground approach to making the HierarchicalSSM compatible with the bootstrap filter. I've add two special dynamics types and when filter is called with BootstrapFilter and HierarchicalSSM, the model is converted to a regular StateSpaceModel using these two special types.

I think a long-term ideal approach would be to introduce methods for dynamics() and observations() which construct the dynamics/observation process on the fly so that the inner functions update, predict can act on the HierarchicalSSM directly. I found this ended up being quite faffy though and require some definitions on what exactly an AbstractStateSpaceModel is which seems like a bit too big of a change to worry about right now (maybe later if we include mixed linear/non-linear models [1].

What do you think @charlesknipp? Fine for now?

[1] F. Lindsten, P. Bunch, S. J. Godsill and T. B. Schön, "Rao-Blackwellized particle smoothers for mixed linear/nonlinear state-space models," 2013 IEEE International Conference on Acoustics, Speech and Signal Processing, Vancouver, BC, Canada, 2013, pp. 6288-6292, doi: 10.1109/ICASSP.2013.6638875. keywords: {Trajectory;Smoothing methods;Monte Carlo methods;Approximation methods;Joints;Vectors;State-space methods;Rao-Blackwellization;particle smoothing;backward simulation;sequential Monte Carlo},

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.

I worry that we add some bloat by storing a cloud of Rao-Blackwellised particles. Consider a user who designed a summary statistic f(x::ParticleDistribution). The internals of that function would need to be rewritten to support the special case of ParticleDistribution{RaoBlackwellisedParticle{XT,ZT},...}.

Regardless, this is a relatively specific concern for an elegant fix. I approve.

Comment on lines +109 to +122
function filter(
rng::AbstractRNG,
model::HierarchicalSSM,
alg::BootstrapFilter,
observations::AbstractVector;
ref_state::Union{Nothing,AbstractVector}=nothing,
kwargs...,
)
ssm = StateSpaceModel(
HierarchicalDynamics(model.outer_dyn, model.inner_model.dyn),
HierarchicalObservations(model.inner_model.obs),
)
return filter(rng, ssm, alg, observations; ref_state=ref_state, kwargs...)
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

I love Julia for this

@THargreaves
Copy link
Collaborator Author

The internals of that function would need to be rewritten to support the special case

That's a fair point, though note that we can't assume that the outer state is a vector (e.g. it could be the jump collection of a Lévy process) so we can't just concatenate them together as vectors.

@THargreaves THargreaves merged commit bd96222 into main Mar 11, 2025
3 of 4 checks passed
@THargreaves THargreaves deleted the th/hierarchical-bf branch March 11, 2025 17:28
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.

2 participants