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

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