Decompose forward function into initialize, predict, update #105
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.
As discussed in #104, this PR takes the existing forward filtering code and decomposes it into separate functions for initialising the filter, predicting the next state and updating the filtered state.
There are a few mildly ugly corners:
logL
is passed into_update!
and returns. This is because thelogL
in storage is not updated until the full forward filtering is completed. This could be resolved by passing ak
argument intoforward!
and updatinglogL[k]
in-place but changing this signature had knock on effects on other algorithms (e.g. Baum-Welch) so I've left for nowt=1
since we just use the initialisation value.On the bright side, this decomposition has made the indexing a bit easier to understand. The loop is now
t1:t2
and the main index used ist
rather thant+1
before.All correctness tests pass but there are few test cases in the AD/temporal examples that are failing. Happy to look into these but @gdalle might be able to instantly spot what's wrong.