Skip to content

Add the nested particle filter of Crisan and Miguez (2018) - #287

Open
Sahel13 wants to merge 10 commits into
mainfrom
nested-pf-v2
Open

Sahel13 wants to merge 10 commits into
mainfrom
nested-pf-v2

Conversation

@Sahel13

@Sahel13 Sahel13 commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Supersedes #243

Ok I've figured out a way to do this a lot more cleanly, reusing much of our existing particle filter code. It's a single file with only about 100 lines of code, and we don't need any parameter-specific types.

So the way this would work from the end user's POV is:

  1. Specify an inner particle filter for the model that is conditioned on a parameter value. The only thing that's changed from the standard PF model declaration is that model_inputs now contains the parameters, and the user has to declare how to package this with an add_param_to_model_inputs function.
  2. Specify the initial distribution for the parameters and the jittering kernel using the existing InitSample and PropagateSample types.
  3. Call the build_filter method that this PR provides.

Wdyt @SamDuffield ? I'll add the docstrings and some docs once we settle on the implementation and the API.

This also has the additional benefit that unlike #243, we can do hybrid filters, where we use a Kalman-type filter for the inner one.

@Sahel13 Sahel13 changed the title nested particle filter of Crisan and Miguez (2018) Add the nested particle filter of Crisan and Miguez (2018) Nov 6, 2026
@Sahel13
Sahel13 marked this pull request as draft November 6, 2026 19:55
@SamDuffield

Copy link
Copy Markdown
Contributor

This looks great. I don't initially love the assumed structure of model_inputs - so far cuthbert has always left it free to be structured however the user likes and I quite like that. I wonder if we could keep this and have an extract_param(model_inputs) function or similar as an additional argument the user specifies?

@Sahel13

Sahel13 commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator Author

I've added a function add_param_to_model_inputs, which now the user needs to specify. Is this what you had in mind?

@Sahel13

Sahel13 commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator Author

Also one point worth mentioning is that unlike the other particle filters, this one needs the unwrapped resampling function (sans ess decorator). This is because we need to keep track of when resampling happens, and this is the only way I could figure out which didn't require changes to the resampling module.

@SamDuffield SamDuffield left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I like this, would be happy to merge with better documentation.

We should also make an issue about the ess decorator not being compatible here, we can maybe modify the resampling API so that it has this tracking there, although that can be a separate PR

Comment thread cuthbert/smc/nested_particle_filter.py Resolved
Comment thread cuthbert/smc/nested_particle_filter.py Resolved
Comment thread cuthbert/smc/nested_particle_filter.py Resolved
Comment thread cuthbert/smc/nested_particle_filter.py Resolved
@Sahel13
Sahel13 marked this pull request as ready for review November 9, 2026 19:17
@Sahel13
Sahel13 requested review from AdrienCorenflos and a balanced review from Copilot November 9, 2026 19:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
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