-
Notifications
You must be signed in to change notification settings - Fork 16
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 importance_sample method to NestedSamples and MCMCSamples #122
add importance_sample method to NestedSamples and MCMCSamples #122
Conversation
Codecov Report
@@ Coverage Diff @@
## master #122 +/- ##
==========================================
+ Coverage 92.72% 92.80% +0.07%
==========================================
Files 16 16
Lines 1458 1473 +15
==========================================
+ Hits 1352 1367 +15
Misses 106 106
Continue to review full report at Codecov.
|
postscript -- mine and Andrew's comments overlap (apologies, I was mid-review and did not see andrew). |
…or passing a single run
@pstoecker, given your work on gambit related importance weighting, you will likely be interested in this PR when it is merged later today, as well as the conversation in #120. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to be a pain in requesting another change, but something I just realised when adjusting the title is that a key thing that this PR is missing is an equivalent method for MCMCSamples
, which would just reweight the logL column. NestedSamples
should then super()
call the reweighting portion, and then recompute the nlive with merge_nested_samples
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work.
One further optional addition is to add an inplace=False optional kwarg to importance_sample
, in the same vein as NestedSamples.set_beta
, and generally quite common in pandas for this kind of large-scale operation.. This would be implemented simply as
def importance_sample(self, logL_new, action='add', inplace=False):
....
if inplace:
self = samples
else:
return samples
The situation here is a tiny bit more complicated than for Typical situations where |
This thing made me wish for docstring inheritance (#22, #24) again... In the current version the docstrings for the |
Many thanks to @andrewfowlie and @williamjameshandley for your helpful input! |
I agree that the current setup requires a lot of work (which still results in inconsistencies). I am wary of any method however which results in non-readable strings in source code. One of the the things I really like about python that the documentation and source are tightly linked in a text file by convention. It would be nice if there were a way of automatically checking docstring consistency via a script (which was fed/interpreted the logical structure), but I'm not sure if such a thing exists. |
As suggested in #120, this PR implements a method for importance re-weighting the nested samples, which allows e.g. discarding/penalising samples as done in #120, but also allows adding to
logL
, e.g. with data from a different experiment.Some things to keep in mind:
Checklist:
flake8 anesthetic tests
)pydocstyle --convention=numpy anesthetic
)python -m pytest
)