1 #ifndef STAN__MCMC__BASE__HMC__BETA
2 #define STAN__MCMC__BASE__HMC__BETA
7 #include <boost/math/special_functions/fpclassify.hpp>
8 #include <boost/random/variate_generator.hpp>
9 #include <boost/random/uniform_01.hpp>
18 template <
class M,
class P,
template<
class,
class>
class H,
19 template<
class,
class>
class I,
class BaseRNG>
24 base_hmc(M &m, BaseRNG& rng, std::ostream* o, std::ostream*
e):
43 std::vector<std::string>& names) {
44 z_.get_param_names(model_names, names);
48 z_.get_params(values);
51 void seed(
const Eigen::VectorXd& q) {
69 double delta_H = H0 - h;
71 int direction = delta_H >
std::log(0.8) ? 1 : -1;
75 this->
z_.ps_point::operator=(z_init);
87 double delta_H = H0 - h;
89 if ((direction == 1) && !(delta_H >
std::log(0.8)))
91 else if ((direction == -1) && !(delta_H <
std::log(0.8)))
98 if (this->nom_epsilon_ > 1e7)
99 throw std::runtime_error(
"Posterior is improper. Please check your model.");
100 if (this->nom_epsilon_ == 0)
101 throw std::runtime_error(
"No acceptably small step size could be found. Perhaps the posterior is not continuous?");
105 this->
z_.ps_point::operator=(z_init);
bool isnan(const stan::agrad::var &v)
Checks if the given number is NaN.
void write_sampler_state(std::ostream *o)
H< M, BaseRNG > hamiltonian_
virtual void set_stepsize_jitter(const double j)
std::ostream * out_stream_
virtual void set_nominal_stepsize(const double e)
void get_sampler_diagnostics(std::vector< double > &values)
std::ostream * err_stream_
double get_stepsize_jitter()
double e()
Return the base of the natural logarithm.
double get_nominal_stepsize()
void get_sampler_diagnostic_names(std::vector< std::string > &model_names, std::vector< std::string > &names)
base_hmc(M &m, BaseRNG &rng, std::ostream *o, std::ostream *e)
void seed(const Eigen::VectorXd &q)
boost::uniform_01< BaseRNG & > rand_uniform_
fvar< T > log(const fvar< T > &x)
double get_current_stepsize()
I< H< M, BaseRNG >, P > integrator_