11 namespace SamplingAlgorithms {
66 DRKernel(boost::property_tree::ptree
const& pt,
67 std::shared_ptr<AbstractSamplingProblem>
problem);
69 DRKernel(boost::property_tree::ptree
const& pt,
70 std::shared_ptr<AbstractSamplingProblem>
problem,
71 std::vector<std::shared_ptr<MCMCProposal>> proposalsIn,
72 std::vector<double> scales);
74 DRKernel(boost::property_tree::ptree
const& pt,
75 std::shared_ptr<AbstractSamplingProblem>
problem,
76 std::vector<std::shared_ptr<MCMCProposal>> proposalsIn);
85 virtual void PostStep(
unsigned int const t,
86 std::vector<std::shared_ptr<SamplingState>>
const& state)
override;
88 virtual std::vector<std::shared_ptr<SamplingState>>
Step(
unsigned int const t,
89 std::shared_ptr<SamplingState> prevState)
override;
96 virtual void PrintStatus(std::string prefix)
const override;
112 std::shared_ptr<SamplingState>
const& state)
const;
118 std::shared_ptr<SamplingState>
const& x,
119 std::shared_ptr<SamplingState>
const& y)
const;
126 virtual void SetBlockInd(
int newBlockInd)
override;
133 static std::vector<std::shared_ptr<MCMCProposal>>
CreateProposals(boost::property_tree::ptree
const& pt,
134 std::shared_ptr<AbstractSamplingProblem>
const&
problem);
142 static std::vector<double>
CreateScales(boost::property_tree::ptree
const& pt);
166 template<
typename VecType1,
typename VecType2>
167 double Alpha(VecType1& likelies, VecType2& proposed_points)
const
171 int stage = likelies.size() - 1;
176 for (
int k = 1;
k < stage; ++
k) {
179 a2 *= (1.0 -
Alpha(slice1, slice2));
183 a1 *= (1.0 -
Alpha(slice1, slice2));
194 for (
int k = 1;
k <= stage; ++
k) {
199 return std::min<double>(1.0, exp(likelies[stage] - likelies[0] + q) * a2 / a1);
202 template<
typename VecType>
203 double QFun(VecType
const& proposed_points)
const
206 int stage = proposed_points.size() - 1;
207 return EvaluateProposal(stage - 1, proposed_points[0], proposed_points[stage]);
An implementation of the delayed rejection kernel.
std::vector< double > propScales
double QFun(VecType const &proposed_points) const
double EvaluateProposal(unsigned int stage, std::shared_ptr< SamplingState > const &x, std::shared_ptr< SamplingState > const &y) const
double Alpha(VecType1 &likelies, VecType2 &proposed_points) const
std::set< std::shared_ptr< MCMCProposal > > uniqueProps
DRKernel(boost::property_tree::ptree const &pt, std::shared_ptr< AbstractSamplingProblem > problem)
static std::vector< double > CreateScales(boost::property_tree::ptree const &pt)
virtual Eigen::VectorXd AcceptanceRates() const
Eigen::VectorXi numProposalCalls
Eigen::VectorXi numProposalAccepts
virtual std::vector< std::shared_ptr< MCMCProposal > > Proposals()
std::vector< std::shared_ptr< MCMCProposal > > proposals
virtual void SetBlockInd(int newBlockInd) override
virtual ~DRKernel()=default
virtual std::vector< std::shared_ptr< SamplingState > > Step(unsigned int const t, std::shared_ptr< SamplingState > prevState) override
static std::vector< std::shared_ptr< MCMCProposal > > CreateProposals(boost::property_tree::ptree const &pt, std::shared_ptr< AbstractSamplingProblem > const &problem)
virtual void PostStep(unsigned int const t, std::vector< std::shared_ptr< SamplingState >> const &state) override
Allow the kernel to adapt given a new state.
std::shared_ptr< SamplingState > SampleProposal(unsigned int stage, std::shared_ptr< SamplingState > const &state) const
std::vector< double > GetScales() const
DRKernel(boost::property_tree::ptree const &pt, std::shared_ptr< AbstractSamplingProblem > problem, std::vector< std::shared_ptr< MCMCProposal >> proposalsIn, std::vector< double > scales)
Defines the transition kernel used by an MCMC algorithm.
std::shared_ptr< AbstractSamplingProblem > problem
The sampling problem that evaluates/samples the target distribution.
virtual void PrintStatus() const
VectorSlice< std::vector< ScalarType >, ScalarType > GetSlice(std::vector< ScalarType > &dataIn, int startIndIn, int endIndIn, int skipIn=1)