7 namespace pt = boost::property_tree;
14 MHProposal::MHProposal(pt::ptree
const& pt,
15 std::shared_ptr<AbstractSamplingProblem> prob) :
18 unsigned int problemDim = prob->blockSizes(blockInd);
21 const Eigen::VectorXd cov = pt.get(
"ProposalVariance", 1.0)*
22 Eigen::VectorXd::Ones(problemDim);
25 proposal = std::make_shared<Gaussian>(Eigen::VectorXd::Zero(problemDim), cov);
28 MHProposal::MHProposal(pt::ptree
const& pt,
29 std::shared_ptr<AbstractSamplingProblem> prob,
30 std::shared_ptr<GaussianBase> proposalIn) :
33 std::shared_ptr<SamplingState> MHProposal::Sample(std::shared_ptr<SamplingState>
const& currentState) {
34 assert(currentState->state.size()>
blockInd);
37 std::vector<Eigen::VectorXd> props = currentState->state;
39 Eigen::VectorXd
const& xc = currentState->state.at(
blockInd);
41 Eigen::VectorXd prop =
proposal->Sample();
45 return std::make_shared<SamplingState>(props, 1.0);
49 std::shared_ptr<SamplingState>
const& propState) {
51 Eigen::VectorXd diff = propState->state.at(
blockInd)-currState->state.at(
blockInd);
REGISTER_MCMC_PROPOSAL(MHProposal) MHProposal
Implementation of the classic Random Walk Metropolis proposal.
virtual double LogDensity(std::shared_ptr< SamplingState > const &currState, std::shared_ptr< SamplingState > const &propState) override
std::shared_ptr< muq::Modeling::GaussianBase > proposal
The proposal distribution.