Compute likelihood via particle filter #14
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Merge after #8, contains those commitsWe'll get better statistical tests on this later, but some poking about with it suggests we're correct :-/
For the future tests, we have a model where we derived the likelihood a different way and show it converges. But for that I need to implement support for compiling models as we go, and that's a few PRs away.
This PR implements the same particle filter algorithm as used in dust1 and mcstate1:
scale_log_weights
)resample_weight
- tbh I forget how this works but the R reference implementation intest-filter-details.R
is actually very simple). This samples, with replacement, particles in proportion to the weight computed in step 3Some future features are flagged in the code
The RNG seeding is complex, and different to the way that we do this in dust1:
n
particles andm
parameter sets we need(n + 1) * m
streamsn + 1
streams go to the first parameter sets, and of that the first stream goes to the filter and the remainingn
go to the model