Stan  1.0
probability, sampling & optimization
sampler.hpp
Go to the documentation of this file.
1 #ifndef __STAN__MCMC__SAMPLER_HPP__
2 #define __STAN__MCMC__SAMPLER_HPP__
3 
4 #include <vector>
5 
6 namespace stan {
7 
8  namespace mcmc {
9 
16  class sample {
17  private:
18  const std::vector<double> params_r_;
19  const std::vector<int> params_i_;
20  const double _log_prob;
21 
22  public:
23 
37  sample(const std::vector<double>& params_r,
38  const std::vector<int>& params_i,
39  double log_prob) :
40  params_r_(params_r),
41  params_i_(params_i),
42  _log_prob(log_prob) {
43  }
44 
50  virtual ~sample() {
51  }
52 
58  inline int size_r() const {
59  return params_r_.size();
60  }
61 
69  inline double params_r(int k) const {
70  return params_r_[k];
71  }
72 
79  inline void params_r(std::vector<double>& x) const {
80  x = params_r_;
81  }
82 
89  inline const std::vector<double>& params_r() const {
90  return params_r_;
91  }
92 
98  inline int size_i() const {
99  return params_i_.size();
100  }
101 
108  inline int params_i(int k) const {
109  return params_i_[k];
110  }
111 
118  inline void params_i(std::vector<int>& n) const {
119  n = params_i_;
120  }
121 
125  inline const std::vector<int>& params_i() const {
126  return params_i_;
127  }
128 
135  inline double log_prob() const {
136  return _log_prob;
137  }
138 
139  };
140 
141 
142 
143 
144 
145 
146  }
147 }
148 
149 #endif
Representation of a MCMC sample.
Definition: sampler.hpp:16
sample(const std::vector< double > &params_r, const std::vector< int > &params_i, double log_prob)
Construct a sample from the specified parameters and log probability.
Definition: sampler.hpp:37
virtual ~sample()
Destroy this sample.
Definition: sampler.hpp:50
int size_i() const
Return the number of discrete integer (discrete) parameters.
Definition: sampler.hpp:98
int size_r() const
Return the number of real (scalar) parameters.
Definition: sampler.hpp:58
const std::vector< int > & params_i() const
Return the vector of integer parameters for this sample.
Definition: sampler.hpp:125
void params_i(std::vector< int > &n) const
Set the specified parameter vector's value to the parameters in this sample.
Definition: sampler.hpp:118
const std::vector< double > & params_r() const
Return the underlying continuous parameter vector.
Definition: sampler.hpp:89
void params_r(std::vector< double > &x) const
Set the specified parameter vector's value to the parameters in this sample.
Definition: sampler.hpp:79
double log_prob() const
Return the log probability (possibly unnormalized) for this sample.
Definition: sampler.hpp:135
double params_r(int k) const
Return the value of the parameter at the specified index.
Definition: sampler.hpp:69
int params_i(int k) const
Return the integer (discrete) parameter at the specified index.
Definition: sampler.hpp:108
Probability, optimization and sampling library.
Definition: agrad.cpp:6

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