7 namespace pt = boost::property_tree;
14 IndependenceProposal::IndependenceProposal(pt::ptree
const& pt,
15 std::shared_ptr<AbstractSamplingProblem>
const& prob) :
IndependenceProposal(pt,prob, ExtractDistribution(pt, prob))
18 IndependenceProposal::IndependenceProposal(pt::ptree
const& pt,
19 std::shared_ptr<AbstractSamplingProblem>
const& prob,
20 std::shared_ptr<Distribution> dist) :
MCMCProposal(pt,prob),
25 std::shared_ptr<Distribution> IndependenceProposal::ExtractDistribution(pt::ptree
const& opts,
26 std::shared_ptr<AbstractSamplingProblem>
const& prob)
29 Eigen::VectorXd mu = Eigen::VectorXd::Zero(
prob->blockSizes(opts.get(
"BlockIndex",0)));
30 Eigen::VectorXd var = opts.get(
"ProposalVariance", 1.0)*Eigen::VectorXd::Ones(mu.size());
32 return std::make_shared<Gaussian>(mu,var);
36 assert(currentState->state.size()>
blockInd);
39 std::vector<Eigen::VectorXd> props = currentState->state;
42 Eigen::VectorXd prop =
proposal->Sample();
46 return std::make_shared<SamplingState>(props, 1.0);
50 std::shared_ptr<SamplingState>
const& propState)
REGISTER_MCMC_PROPOSAL(IndependenceProposal) IndependenceProposal
Implementation of an independence proposal with arbitrary distribution.
virtual std::shared_ptr< SamplingState > Sample(std::shared_ptr< SamplingState > const ¤tState) override
virtual double LogDensity(std::shared_ptr< SamplingState > const &currState, std::shared_ptr< SamplingState > const &propState) override
std::shared_ptr< muq::Modeling::Distribution > proposal
The proposal distribution.
std::shared_ptr< AbstractSamplingProblem > prob