14 std::shared_ptr<AbstractSamplingProblem> prob) :
16 stepSize(pt.
get(
"StepSize",1.0))
18 rho = (4.0 - stepSize) / (4.0 + stepSize);
20 unsigned int dim = prob->blockSizes(blockInd);
22 const Eigen::VectorXd cov = Eigen::VectorXd::Ones(dim);
23 zDist = std::make_shared<Gaussian>(Eigen::VectorXd::Zero(dim), cov);
28 InfMALAProposal::InfMALAProposal(boost::property_tree::ptree
const& pt,
29 std::shared_ptr<AbstractSamplingProblem> prob,
30 std::shared_ptr<GaussianBase> zDistIn) :
33 stepSize(pt.
get(
"StepSize",1.0))
40 assert(currentState->state.size()>
blockInd);
43 std::vector<Eigen::VectorXd> props = currentState->state;
45 Eigen::VectorXd
const& uc = currentState->state.at(
blockInd);
53 return std::make_shared<SamplingState>(props, 1.0);
57 std::shared_ptr<SamplingState>
const& propState)
59 double const beta = sqrt(1 -
rho*
rho);
62 Eigen::VectorXd diff = (propState->state.at(
blockInd) - mean)/beta;
64 return zDist->LogDensity(diff);
70 std::stringstream blockId;
73 if(!state->HasMeta(
"MALA_SigmaGrad" + blockId.str())){
76 if(!state->HasMeta(
"GradLogDensity" + blockId.str()))
77 state->meta[
"GradLogDensity" + blockId.str()] =
prob->GradLogDensity(state,
blockInd);
79 grad =
AnyCast( state->meta[
"GradLogDensity" + blockId.str()] );
81 state->meta[
"MALA_SigmaGrad" + blockId.str()] =
zDist->ApplyCovariance(grad).col(0).eval();
84 Eigen::VectorXd sigmaGrad =
AnyCast(state->meta[
"MALA_SigmaGrad" + blockId.str()]);
REGISTER_MCMC_PROPOSAL(InfMALAProposal) InfMALAProposal
An implement of the dimension-independent MALA (or Inf-MALA) proposal.
virtual double LogDensity(std::shared_ptr< SamplingState > const &currState, std::shared_ptr< SamplingState > const &propState) override
InfMALAProposal(boost::property_tree::ptree const &pt, std::shared_ptr< AbstractSamplingProblem > prob)
virtual std::shared_ptr< SamplingState > Sample(std::shared_ptr< SamplingState > const ¤tState) override
std::shared_ptr< muq::Modeling::GaussianBase > zDist
Eigen::VectorXd GetSigmaGrad(std::shared_ptr< SamplingState > const ¤tState) const
std::shared_ptr< AbstractSamplingProblem > prob
Class for easily casting boost::any's in assignment operations.
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())