1 #ifndef STAN__MCMC__BASE__HAMILTONIAN__BETA
2 #define STAN__MCMC__BASE__HAMILTONIAN__BETA
16 template <
typename M,
typename P,
typename BaseRNG>
24 virtual double T(P& z) = 0;
25 double V(P& z) {
return z.V; }
27 virtual double tau(P& z) = 0;
28 virtual double phi(P& z) = 0;
30 double H(P& z) {
return T(z) +
V(z); }
33 virtual const Eigen::VectorXd
dtau_dq(P& z) = 0;
34 virtual const Eigen::VectorXd
dtau_dp(P& z) = 0;
37 virtual const Eigen::VectorXd
dphi_dq(P& z) = 0;
39 virtual void sample_p(P& z, BaseRNG& rng) = 0;
48 }
catch (
const std::exception&
e) {
50 z.V = std::numeric_limits<double>::infinity();
64 const std::exception&
e) {
66 if (!error_msgs)
return;
68 *error_msgs << std::endl
69 <<
"Informational Message: The current Metropolis proposal is about to be "
70 <<
"rejected because of the following issue:"
72 << e.what() << std::endl
73 <<
"If this warning occurs sporadically, such as for highly constrained "
74 <<
"variable types like covariance matrices, then the sampler is fine,"
76 <<
"but if this warning occurs often then your model may be either severely "
77 <<
"ill-conditioned or misspecified."
virtual void sample_p(P &z, BaseRNG &rng)=0
virtual void update(P &z)
virtual const Eigen::VectorXd dphi_dq(P &z)=0
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 const Eigen::VectorXd dtau_dp(P &z)=0
void write_error_msg_(std::ostream *error_msgs, const std::exception &e)
virtual double tau(P &z)=0
base_hamiltonian(M &m, std::ostream *e)
virtual double phi(P &z)=0
virtual const Eigen::VectorXd dtau_dq(P &z)=0
std::ostream * err_stream_
double e()
Return the base of the natural logarithm.