-
Notifications
You must be signed in to change notification settings - Fork 155
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
Importance sampler #692
Importance sampler #692
Conversation
3252189
to
fdcaaf3
Compare
Codecov Report
@@ Coverage Diff @@
## main #692 +/- ##
==========================================
- Coverage 77.30% 76.47% -0.83%
==========================================
Files 76 78 +2
Lines 5869 5930 +61
==========================================
- Hits 4537 4535 -2
- Misses 1332 1395 +63
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
fdcaaf3
to
7395bcc
Compare
68bf102
to
d86e78b
Compare
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.
Great PR!
see comments below.
Great to have the additional sampling methods as Posteriors as well! |
c585346
to
9cd0682
Compare
c74206b
to
497383c
Compare
This implements an
ImportanceSamplingPosterior
.This posterior behaves as follows:
log_prob()
: estimates the normalization constant of thepotential_fn
with importance sampling and then returns thepotential_fn(theta) - log(norm_constant)
.sample()
: Depending onmethod
, it either returns samples from theproposal
and their corresponding importance weights or it samples with SIR (default)Also, I realized that the "sir" init in MCMC does not actually perform SIR. SIR resamples with weights
p(theta|x) / q(theta)
, but our weights were simplyp(theta|x)
. I renamed this init toresample
.resample
is also the default. Settinginit_strategy='sir'
will perform "actual" SIR.