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

slice_numpy_mcmc tuning fix #1174

Merged
merged 2 commits into from
Jun 17, 2024
Merged

Conversation

gmoss13
Copy link
Contributor

@gmoss13 gmoss13 commented Jun 14, 2024

What does this implement/fix? Explain your changes

fixes inf values being returned by the slice_numpy mcmc sampler

Does this close any currently open issues?

Fixes #1060. Also related to #910

Any other comments?

The issue was not in the sampler "diverging", c.f. #910:

The main reason seems to be the number of warmup steps. If it is too small, chains have not converged and samples diverge (why?)

Instead, we generated the samples to return initially with np.empty(), but did not account for the tuning of the bracket width, so we never defined the first entries of the sampels returned. This is why increasing warm up steps also fixed the issue - the nan values were completely removed if the warm_up steps were increased enough.

@gmoss13 gmoss13 linked an issue Jun 14, 2024 that may be closed by this pull request
@gmoss13
Copy link
Contributor Author

gmoss13 commented Jun 14, 2024

As a side note, the code for the slice sampler is not very well documented, so it was time consuming for me to find this bug because first I had to decipher the code. Could add some documentation here in this PR?

@gmoss13 gmoss13 requested a review from janfb June 14, 2024 14:04
Copy link

codecov bot commented Jun 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 72.91%. Comparing base (8efb8e4) to head (ec2c4da).

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1174       +/-   ##
===========================================
- Coverage   83.69%   72.91%   -10.79%     
===========================================
  Files          93       93               
  Lines        7397     7399        +2     
===========================================
- Hits         6191     5395      -796     
- Misses       1206     2004      +798     
Flag Coverage Δ
unittests 72.91% <100.00%> (-10.79%) ⬇️

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

Files Coverage Δ
sbi/samplers/mcmc/slice_numpy.py 92.05% <100.00%> (+0.06%) ⬆️

... and 24 files with indirect coverage changes

@janfb
Copy link
Contributor

janfb commented Jun 14, 2024

Great catch! 👏
Absolutely, if you could add some documentation that would be awesome

Copy link
Contributor

@janfb janfb left a comment

Choose a reason for hiding this comment

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

Looks good! thanks for fixing this! 👏

@gmoss13 gmoss13 merged commit ea1cc20 into main Jun 17, 2024
6 checks passed
@gmoss13 gmoss13 deleted the 1060-mcmc-sampler-generates-inf-values branch June 17, 2024 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MCMC sampler generates inf values
2 participants