Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
unit_e_metric.hpp
Go to the documentation of this file.
1 #ifndef STAN__MCMC__UNIT__E__METRIC__BETA
2 #define STAN__MCMC__UNIT__E__METRIC__BETA
3 
4 #include <boost/random/variate_generator.hpp>
5 #include <boost/random/normal_distribution.hpp>
6 
9 
10 namespace stan {
11 
12  namespace mcmc {
13 
14  // Euclidean manifold with unit metric
15  template <typename M, typename BaseRNG>
16  class unit_e_metric: public base_hamiltonian<M, unit_e_point, BaseRNG> {
17 
18  public:
19 
20  unit_e_metric(M& m, std::ostream* e):
21  base_hamiltonian<M, unit_e_point, BaseRNG>(m, e) {};
23 
24  double T(unit_e_point& z) {
25  return 0.5 * z.p.squaredNorm();
26  }
27 
28  double tau(unit_e_point& z) { return T(z); }
29  double phi(unit_e_point& z) { return this->V(z); }
30 
31  const Eigen::VectorXd dtau_dq(unit_e_point& z) {
32  return Eigen::VectorXd::Zero(this->model_.num_params_r());
33  }
34 
35  const Eigen::VectorXd dtau_dp(unit_e_point& z) {
36  return z.p;
37  }
38 
39  const Eigen::VectorXd dphi_dq(unit_e_point& z) {
40  return z.g;
41  }
42 
43  void sample_p(unit_e_point& z, BaseRNG& rng) {
44 
45  boost::variate_generator<BaseRNG&, boost::normal_distribution<> >
46  rand_unit_gaus(rng, boost::normal_distribution<>());
47 
48  for (int i = 0; i < z.p.size(); ++i)
49  z.p(i) = rand_unit_gaus();
50 
51  }
52 
53  };
54 
55  } // mcmc
56 
57 } // stan
58 
59 
60 #endif
const Eigen::VectorXd dtau_dq(unit_e_point &z)
double phi(unit_e_point &z)
Eigen::VectorXd p
Definition: ps_point.hpp:48
const Eigen::VectorXd dtau_dp(unit_e_point &z)
Eigen::VectorXd g
Definition: ps_point.hpp:51
const Eigen::VectorXd dphi_dq(unit_e_point &z)
double tau(unit_e_point &z)
double T(unit_e_point &z)
void sample_p(unit_e_point &z, BaseRNG &rng)
double e()
Return the base of the natural logarithm.
Definition: constants.hpp:86
unit_e_metric(M &m, std::ostream *e)

     [ Stan Home Page ] © 2011–2014, Stan Development Team.