Skip to content
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 Accumulated State Densities Filter #734

Merged
merged 19 commits into from
Oct 27, 2022
Merged

Add Accumulated State Densities Filter #734

merged 19 commits into from
Oct 27, 2022

Conversation

sdhiscocks
Copy link
Member

This is an update of #309 by @jogehl to latest version of Stone Soup.

Changes to core code are minor tidy up for readability, some minor changes based on comments from #309, and moving to separate sub-module from Kalman.

Tutorial has also been updated to take advantage of newer animation and plotly features.

@sdhiscocks sdhiscocks requested a review from a team as a code owner October 7, 2022 12:27
@sdhiscocks sdhiscocks requested review from nperree-dstl and hpritchett-dstl and removed request for a team October 7, 2022 12:27
@codecov
Copy link

codecov bot commented Oct 7, 2022

Codecov Report

Base: 94.79% // Head: 94.90% // Increases project coverage by +0.10% 🎉

Coverage data is based on head (fc026ee) compared to base (a17fb42).
Patch coverage: 98.66% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #734      +/-   ##
==========================================
+ Coverage   94.79%   94.90%   +0.10%     
==========================================
  Files         168      170       +2     
  Lines        8190     8413     +223     
  Branches     1560     1234     -326     
==========================================
+ Hits         7764     7984     +220     
- Misses        317      318       +1     
- Partials      109      111       +2     
Flag Coverage Δ
integration 69.99% <92.88%> (+0.62%) ⬆️
unittests 91.95% <69.33%> (-0.63%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
stonesoup/updater/kalman.py 95.72% <ø> (ø)
stonesoup/updater/asd.py 95.00% <95.00%> (ø)
stonesoup/types/state.py 99.74% <98.64%> (-0.26%) ⬇️
stonesoup/predictor/asd.py 100.00% <100.00%> (ø)
stonesoup/predictor/kalman.py 90.90% <100.00%> (ø)
stonesoup/types/prediction.py 100.00% <100.00%> (ø)
stonesoup/types/update.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

By using the original Kalman methods, subscripting the ASD Gaussian
State, this should also more easily enable the other Kalman variants.
This also removes the original transition function method which was
unused.
@sdhiscocks
Copy link
Member Author

Code coverage highlighted that _transition_function wasn't used in predictor, so I did a little refactor to make use of the parent _transition_function and removed custom pred function. Extend and other variants in theory should be easier to add in future.

covars = \
[prior.multi_covar[i * ndim:(i+1) * ndim, i * ndim:(i+1) * ndim]
for i in range(t_index)]
covars.append(p_pred_m)
Copy link
Member Author

@sdhiscocks sdhiscocks Oct 13, 2022

Choose a reason for hiding this comment

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

I think this should be p_pred_m_cr rather than p_pred_m. Changing this, it seems to give better and more stable results, whereas without changing it, the estimates look wrong.

Copy link
Member Author

@sdhiscocks sdhiscocks Oct 14, 2022

Choose a reason for hiding this comment

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

I've changed this in bc3e360, which also includes changing the covariances stored in correlation matrices, as I believe this were the wrong way around.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for the late answer. You are right. This was an error in my implementation.

Based on equation 20 from 1st reference, verifying based on
equations 69-75 from 2nd reference, it seems the predicted covariance
given m-1 and given k were switched in there usage after calculation.
@sdhiscocks
Copy link
Member Author

@jogehl Thanks again for your contribution, and sorry about significant delay getting to your original pull request. I wasn't sure if you were still active on GitHub.

I wanted to add you to the copyright authors list, but wasn't sure whether to put your name or company/institution that you are/were based at when you did this work?

@jogehl
Copy link
Contributor

jogehl commented Oct 17, 2022

@sdhiscocks if you like you can put the Fraunhofer FKIE to the contributors' list.

sdhiscocks and others added 3 commits October 17, 2022 12:58
Given other elements of the state are all accessed by index, it is
preferable to also have correlation matrices to be the same, to ensure
that entire state stays aligned. In particular in edge case where two
estimates may be present at the same timestamp.
stonesoup/predictor/asd.py Outdated Show resolved Hide resolved
docs/tutorials/filters/ASDFilter.py Outdated Show resolved Hide resolved
Copy link
Contributor

@nperree-dstl nperree-dstl left a comment

Choose a reason for hiding this comment

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

This all works/makes sense as far as I can tell. Could possibly do with a bit more explanation in the tutorial as to how the filter works but otherwise I think it looks good!

@sdhiscocks sdhiscocks merged commit cf0dba1 into main Oct 27, 2022
@sdhiscocks sdhiscocks deleted the accum_state_dens branch October 27, 2022 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants