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

Rework rejection sampling #358

Merged
merged 15 commits into from
Dec 13, 2023
Merged

Rework rejection sampling #358

merged 15 commits into from
Dec 13, 2023

Conversation

mj-will
Copy link
Owner

@mj-will mj-will commented Dec 11, 2023

This PR reworks the rejection sampling in the proposal classes so they accumulate samples until sufficient samples are obtained, rather than apply rejection sampling to each batch of samples. This should improve the estimate of the normalisation constant.

Main changes

  • Rework FlowProposal.populate

Other changes
Whilst making these changes, I made a couple of other minor changes:

  • The population time no longer includes the time spent evaluating the log-likelihood
  • FlowProposal.compute_weights no longer normalises the weights and can also return the value of the log-prior rather than updating the samples in place
  • The population acceptance is now computed based on all the accepted samples rather than the N final samples. Previously, this meant that the reported acceptance could be lower than the actual value.
  • Added a deprecation warning to FlowProposal.rejection_sampling since it is no longer used.
  • FlowProposal.plot_pool no longer takes z as argument
  • Refactor some tests

@mj-will mj-will added enhancement New feature or request breaking changes Breaking API change labels Dec 11, 2023
@mj-will mj-will added this to the v0.12.0 milestone Dec 11, 2023
@mj-will mj-will requested a review from johnveitch December 11, 2023 16:28
Copy link

codecov bot commented Dec 11, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (b389742) 93.29% compared to head (992dd43) 93.32%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #358      +/-   ##
==========================================
+ Coverage   93.29%   93.32%   +0.02%     
==========================================
  Files          67       67              
  Lines        6327     6338      +11     
==========================================
+ Hits         5903     5915      +12     
+ Misses        424      423       -1     
Flag Coverage Δ
unittests 93.32% <100.00%> (+0.02%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mj-will mj-will mentioned this pull request Dec 11, 2023
@mj-will mj-will force-pushed the rework-rejection-sampling branch from c04e64f to 992dd43 Compare December 13, 2023 13:42
@mj-will mj-will merged commit ee2a238 into main Dec 13, 2023
30 checks passed
@mj-will mj-will deleted the rework-rejection-sampling branch December 13, 2023 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking changes Breaking API change enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants