1 #ifndef STAN_MCMC_HMC_UNIFORM_BASE_STATIC_UNIFORM_HPP
2 #define STAN_MCMC_HMC_UNIFORM_BASE_STATIC_UNIFORM_HPP
7 #include <boost/math/special_functions/fpclassify.hpp>
8 #include <boost/random/uniform_int_distribution.hpp>
21 template <
class Model,
22 template<
class,
class>
class Hamiltonian,
23 template<
class>
class Integrator,
26 public base_hmc<Model, Hamiltonian, Integrator, BaseRNG> {
29 :
base_hmc<Model, Hamiltonian, Integrator, BaseRNG>(model, rng),
52 double sum_metro_prob = 1;
54 boost::random::uniform_int_distribution<> uniform(0,
L_ - 1);
57 for (
int l = 0; l < Lp; ++l) {
60 info_writer, error_writer);
63 if (boost::math::isnan(h))
64 h = std::numeric_limits<double>::infinity();
66 double prob = std::exp(H0 - h);
68 sum_metro_prob += prob > 1 ? 1 : prob;
74 this->
z_.ps_point::operator=(z_init);
76 for (
int l = 0; l <
L_ - 1 - Lp; ++l) {
79 info_writer, error_writer);
82 if (boost::math::isnan(h))
83 h = std::numeric_limits<double>::infinity();
85 double prob = std::exp(H0 - h);
87 sum_metro_prob += prob > 1 ? 1 : prob;
93 double accept_prob = sum_metro_prob /
static_cast<double>(
L_);
95 this->
z_.ps_point::operator=(z_sample);
98 - this->hamiltonian_.V(this->z_),
103 names.push_back(
"stepsize__");
104 names.push_back(
"int_time__");
105 names.push_back(
"energy__");
110 values.push_back(this->
T_);
111 values.push_back(this->
energy_);
115 if (e > 0 && t > 0) {
123 if (e > 0 && l > 0) {
158 L_ = L_ < 1 ? 1 :
L_;
Hamiltonian< Model, BaseRNG >::PointType z_
void sample(stan::mcmc::base_mcmc *sampler, int num_warmup, int num_samples, int num_thin, int refresh, bool save, stan::services::sample::mcmc_writer< Model, SampleRecorder, DiagnosticRecorder, MessageRecorder > &mcmc_writer, stan::mcmc::sample &init_s, Model &model, RNG &base_rng, const std::string &prefix, const std::string &suffix, std::ostream &o, StartTransitionCallback &callback, interface_callbacks::writer::base_writer &info_writer, interface_callbacks::writer::base_writer &error_writer)
Probability, optimization and sampling library.
Point in a generic phase space.
double cont_params(int k) const
base_writer is an abstract base class defining the interface for Stan writer callbacks.
void seed(const Eigen::VectorXd &q)
boost::uniform_01< BaseRNG & > rand_uniform_
Hamiltonian< Model, BaseRNG > hamiltonian_
Integrator< Hamiltonian< Model, BaseRNG > > integrator_