Open dustinvtran opened 7 years ago
Yep, I think that makes sense. The simplest version to get started would follow Metropolis-Hastings' build_update()
but without the Metropolis correction. This would implement vanilla importance sampling.
Hi, I'm working on an implementation of IS (a first step before SMC) and I was thinking of the two following options:
Implement an ImportanceSampling
class inheriting from MonteCarlo
. The build_update()
method would simply compute one sample from the prior and its the importance weight (likelihood ratio). Each iteration would store its result internally and only in populate the user's Empirical
in the finalize()
method by sampling the auto-normalized weighted approximation.
Implement a WeightedEmpirical
distribution, make Empirical
inherit from it (with default weights of 1/N
) and replace in MonteCarlo
the Empirical
requirement by WeightedEmpirical
. Then at each iteration directly populate the user's WeightedEmpirical
and auto-normalize the distribution in the finalize()
method.
Which of these two options do you think make more sense? Or would you have any other suggestions / comments?
I'm not a contributor, so take this with a grain of salt, but a WeightedEmpirical
distribution makes more sense to me than keeping the weights internal to ImportanceSampling
. It's convenient to be able to access the underlying samples & weights for approximating integrals without experiencing another round of sampling error.
Hi @dustinvtran, I've been going through the codebase to figure out how to best implement SMC, and was looking for a little validation. Would subclassing from MonteCarlo and drawing inspiration from the Metropolis-Hastings implementation be the right way to go about it?