MUQ  0.4.3
ISKernel.cpp
Go to the documentation of this file.
2 
3 namespace pt = boost::property_tree;
4 using namespace muq::Modeling;
5 using namespace muq::SamplingAlgorithms;
6 
8 
9 ISKernel::ISKernel(pt::ptree const& pt, std::shared_ptr<SamplingProblem> problem) : TransitionKernel(pt, problem) {}
10 
11 ISKernel::~ISKernel() {}
12 
14  const boost::any state = problem->SampleBiasingDistribution(inputs);
15 
16  ref_vector<boost::any> dist_inputs(inputs.begin(), inputs.end());
17  dist_inputs.insert(dist_inputs.begin(), std::cref(state));
18 
19  const double logTarget = problem->EvaluateLogTarget(dist_inputs);
20  const double logBias = problem->EvaluateLogBiasingDistribution(dist_inputs);
21 
22  outputs.resize(1);
23  outputs[0] = std::make_shared<SamplingState>(state, std::exp(logTarget-logBias));
24 }
REGISTER_TRANSITION_KERNEL(ISKernel) ISKernel
Definition: ISKernel.cpp:7
Importance sampling transition kernel.
Definition: ISKernel.h:13
virtual void EvaluateImpl(muq::Modeling::ref_vector< boost::any > const &inputs) override
Definition: ISKernel.cpp:13
Defines the transition kernel used by an MCMC algorithm.
std::shared_ptr< AbstractSamplingProblem > problem
The sampling problem that evaluates/samples the target distribution.
std::vector< std::reference_wrapper< const T > > ref_vector
A vector of references to something ...
Definition: WorkPiece.h:37