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

Create regulariser object and MCMC particle regulariser #785

Merged
merged 7 commits into from
Apr 11, 2023

Conversation

timothy-glover
Copy link
Contributor

Created the regulariser object for optional use with particle filters when impoverishment is a problem. This has included the class MCMCRegulariser that follows a particular implementation using the Metropolis-Hastings algorithm (referenced appropriately in the docs).

@timothy-glover timothy-glover requested a review from a team as a code owner March 30, 2023 13:26
@timothy-glover timothy-glover requested review from mharris-dstl and spike-dstl and removed request for a team March 30, 2023 13:26
@nperree-dstl nperree-dstl requested review from nperree-dstl and jswright-dstl and removed request for mharris-dstl and spike-dstl March 30, 2023 13:30
@codecov
Copy link

codecov bot commented Mar 30, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.02 🎉

Comparison is base (bf40a9a) 94.87% compared to head (8933451) 94.89%.

❗ Current head 8933451 differs from pull request most recent head de58ec5. Consider uploading reports for the commit de58ec5 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #785      +/-   ##
==========================================
+ Coverage   94.87%   94.89%   +0.02%     
==========================================
  Files         176      179       +3     
  Lines        9757     9801      +44     
  Branches     1938     1942       +4     
==========================================
+ Hits         9257     9301      +44     
  Misses        356      356              
  Partials      144      144              
Flag Coverage Δ
integration 68.08% <27.27%> (-0.21%) ⬇️
unittests 89.95% <100.00%> (+0.04%) ⬆️

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

Impacted Files Coverage Δ
stonesoup/regulariser/__init__.py 100.00% <100.00%> (ø)
stonesoup/regulariser/base.py 100.00% <100.00%> (ø)
stonesoup/regulariser/particle.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 in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@sdhiscocks sdhiscocks requested review from sdhiscocks and removed request for jswright-dstl April 5, 2023 09:29
stonesoup/regulariser/particle.py Outdated Show resolved Hide resolved
stonesoup/regulariser/particle.py Outdated Show resolved Hide resolved
Comment on lines 89 to 91
for detection in detections:
move_meas_likelihood.append(measurement_model.logpdf(detection, moved_particles))
post_meas_likelihood.append(measurement_model.logpdf(detection, moved_particles))
Copy link
Member

Choose a reason for hiding this comment

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

Just to save calling logpdf twice.

Suggested change
for detection in detections:
move_meas_likelihood.append(measurement_model.logpdf(detection, moved_particles))
post_meas_likelihood.append(measurement_model.logpdf(detection, moved_particles))
for detection in detections:
likelihood = measurement_model.logpdf(detection, moved_particles)
move_meas_likelihood.append(likelihood)
post_meas_likelihood.append(likelihood)

Copy link
Member

Choose a reason for hiding this comment

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

Actually, is this an error, and they shouldn't be the same? From variable names looks like it should be posterior.

Suggested change
for detection in detections:
move_meas_likelihood.append(measurement_model.logpdf(detection, moved_particles))
post_meas_likelihood.append(measurement_model.logpdf(detection, moved_particles))
for detection in detections:
move_meas_likelihood.append(measurement_model.logpdf(detection, moved_particles))
post_meas_likelihood.append(measurement_model.logpdf(detection, posterior))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Amended in latest commit

Comment on lines 98 to 99
alpha = (move_meas_likelihood[max_likelihood_idx]*move_likelihood) / \
(post_meas_likelihood[max_likelihood_idx]*post_likelihood)
Copy link
Member

Choose a reason for hiding this comment

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

move_likelihood and post_likelihood are from pdf, and move_meas_likelihood and post_meas_likelihood are using logpdf. Is this right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, there is a mismatch between logpdf and pdf. I have changed the move_likelihood and post_likelihood to also be logpdf and changed the calculation of alpha accordingly.

timothy-glover and others added 3 commits April 11, 2023 09:39
remove copies

Co-authored-by: Steven Hiscocks <sdhiscocks@dstl.gov.uk>
Co-authored-by: Steven Hiscocks <sdhiscocks@dstl.gov.uk>
@sdhiscocks sdhiscocks merged commit a766c4f into dstl:main Apr 11, 2023
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