Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
covar_adaptation.hpp
Go to the documentation of this file.
1 #ifndef STAN__MCMC__COVAR__ADAPTATION__BETA
2 #define STAN__MCMC__COVAR__ADAPTATION__BETA
3 
4 #include <vector>
6 
9 
10 namespace stan {
11 
12  namespace mcmc {
13 
15 
16  public:
17 
18  covar_adaptation(int n): windowed_adaptation("covariance"), estimator_(n) {}
19 
20  bool learn_covariance(Eigen::MatrixXd& covar, const Eigen::VectorXd& q) {
21 
23 
24  if (end_adaptation_window()) {
25 
27 
29 
30  double n = static_cast<double>(estimator_.num_samples());
31  covar = (n / (n + 5.0)) * covar
32  + 1e-3 * (5.0 / (n + 5.0)) * Eigen::MatrixXd::Identity(covar.rows(), covar.cols());
33 
35 
37  return true;
38 
39  }
40 
42  return false;
43 
44  }
45 
46  protected:
47 
49 
50  };
51 
52  } // mcmc
53 
54 } // stan
55 
56 #endif
void sample_covariance(Eigen::MatrixXd &covar)
prob::welford_covar_estimator estimator_
bool learn_covariance(Eigen::MatrixXd &covar, const Eigen::VectorXd &q)
double e()
Return the base of the natural logarithm.
Definition: constants.hpp:86
void add_sample(const Eigen::VectorXd &q)

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