1 #ifndef STAN_MCMC_HMC_HAMILTONIANS_BASE_HAMILTONIAN_HPP
2 #define STAN_MCMC_HMC_HAMILTONIANS_BASE_HAMILTONIAN_HPP
5 #include <stan/math/prim/mat/fun/Eigen.hpp>
15 template <
class Model,
class Po
int,
class BaseRNG>
25 virtual double T(Point& z) = 0;
31 virtual double tau(Point& z) = 0;
33 virtual double phi(Point& z) = 0;
46 virtual Eigen::VectorXd
dtau_dq(
51 virtual Eigen::VectorXd
dtau_dp(Point& z) = 0;
54 virtual Eigen::VectorXd
dphi_dq(
59 virtual void sample_p(Point& z, BaseRNG& rng) = 0;
72 z.V = -stan::model::log_prob_propto<true>(
model_, z.q);
73 }
catch (
const std::exception& e) {
75 z.V = std::numeric_limits<double>::infinity();
86 }
catch (
const std::exception& e) {
88 z.V = std::numeric_limits<double>::infinity();
116 writer(
"Informational Message: The current Metropolis proposal "
117 "is about to be rejected because of the following issue:");
119 writer(
"If this warning occurs sporadically, such as for highly "
120 "constrained variable types like covariance matrices, then "
121 "the sampler is fine,");
123 writer(
"but if this warning occurs often then your model may be "
124 "either severely ill-conditioned or misspecified.");
virtual double T(Point &z)=0
Probability, optimization and sampling library.
virtual Eigen::VectorXd dtau_dp(Point &z)=0
void write_error_msg_(const std::exception &e, interface_callbacks::writer::base_writer &writer)
virtual double tau(Point &z)=0
void update_metric_gradient(Point &z, interface_callbacks::writer::base_writer &info_writer, interface_callbacks::writer::base_writer &error_writer)
void gradient(const M &model, const Eigen::Matrix< double, Eigen::Dynamic, 1 > &x, double &f, Eigen::Matrix< double, Eigen::Dynamic, 1 > &grad_f, std::ostream *msgs=0)
virtual double phi(Point &z)=0
void update_gradients(Point &z, interface_callbacks::writer::base_writer &info_writer, interface_callbacks::writer::base_writer &error_writer)
void update_potential_gradient(Point &z, interface_callbacks::writer::base_writer &info_writer, interface_callbacks::writer::base_writer &error_writer)
virtual Eigen::VectorXd dphi_dq(Point &z, interface_callbacks::writer::base_writer &info_writer, interface_callbacks::writer::base_writer &error_writer)=0
virtual void sample_p(Point &z, BaseRNG &rng)=0
base_writer is an abstract base class defining the interface for Stan writer callbacks.
virtual double dG_dt(Point &z, interface_callbacks::writer::base_writer &info_writer, interface_callbacks::writer::base_writer &error_writer)=0
void update_metric(Point &z, interface_callbacks::writer::base_writer &info_writer, interface_callbacks::writer::base_writer &error_writer)
void update_potential(Point &z, interface_callbacks::writer::base_writer &info_writer, interface_callbacks::writer::base_writer &error_writer)
base_hamiltonian(const Model &model)
void init(Point &z, interface_callbacks::writer::base_writer &info_writer, interface_callbacks::writer::base_writer &error_writer)
virtual Eigen::VectorXd dtau_dq(Point &z, interface_callbacks::writer::base_writer &info_writer, interface_callbacks::writer::base_writer &error_writer)=0