versatile-mcmc  0.1.7
proposal.hpp
Go to the documentation of this file.
1 
14 #ifndef VMCMC_PROPOSAL_H_
15 #define VMCMC_PROPOSAL_H_
16 
17 #include <vmcmc/blas.hpp>
18 #include <vmcmc/parameter.hpp>
19 #include <vmcmc/sample.hpp>
20 #include <vmcmc/random.hpp>
21 
22 namespace vmcmc
23 {
24 
30 class Proposal
31 {
32 public:
33  Proposal() { }
34  virtual ~Proposal() { }
35 
36  virtual Proposal* Clone() const = 0;
37 
44  virtual double Transition(const Vector& s1, Vector& s2) = 0;
45 
46  double Transition(const Sample& s1, Sample& s2) { return Transition(s1.Values(), s2.Values()); }
47 
48  virtual void UpdateParameterConfig(const ParameterConfig& /*paramConfig*/) { };
49 };
50 
51 
58 template <typename DistributionT>
60 {
61 public:
62  ProposalDistribution(DistributionT&& dist = DistributionT()) :
63  fDistribution( std::forward<DistributionT>(dist) ),
64  fCholeskyDecomp( ublas::identity_matrix<double>() )
65  { }
66  virtual ~ProposalDistribution() { }
67 
68  double Transition(const Vector& s1, Vector& s2) override;
70 
71  void UpdateParameterConfig(const ParameterConfig& paramConfig) override;
72 
73  const MatrixLower& GetCholeskyDecomp() const { return fCholeskyDecomp; }
74 
75 protected:
76  DistributionT fDistribution;
77  MatrixLower fCholeskyDecomp;
78 };
79 
83 class ProposalNormal : public ProposalDistribution< std::normal_distribution<double> >
84 {
85 public:
86  ProposalNormal() { }
87  virtual ~ProposalNormal() { }
88 
89  virtual ProposalNormal* Clone() const override { return new ProposalNormal(*this); }
90 };
91 
95 class ProposalStudentT : public ProposalDistribution< std::student_t_distribution<double> >
96 {
97 public:
98  ProposalStudentT(double dof = 1.0) :
99  ProposalDistribution(std::student_t_distribution<double>(dof)) { }
100  virtual ~ProposalStudentT() { }
101 
102  virtual ProposalStudentT* Clone() const override { return new ProposalStudentT(*this); }
103 
104  void SetDOF(double n = 1.0) { fDistribution = std::student_t_distribution<double>(n); }
105  double GetDOF() const { return fDistribution.n(); }
106 };
107 
108 } /* namespace vmcmc */
109 
110 #endif /* VMCMC_PROPOSAL_H_ */
Abstract proposal function class, which randomly draws from a multivariate random distribution center...
Definition: proposal.hpp:59
Definition: algorithm.cpp:28
A list of parameters, describing the parameter space of the target function to be evaluated...
Definition: parameter.hpp:109
Base class for proposal functions (alias transition kernels) used by Metropolis-Hastings algorithms t...
Definition: proposal.hpp:30
Contains the Sample class definition for data sampled from the target parameter space.
virtual double Transition(const Vector &s1, Vector &s2)=0
Propose a new state.
BLAS (Basic Linear Algebra Subprograms) utility functions.
Proposal function drawing randomly from a multivariate Student-T distribution.
Definition: proposal.hpp:95
Contains the prototype class for thread-safe random number generators.
Proposal function drawing randomly from a multivariate normal distribution.
Definition: proposal.hpp:83
Class definitions representing input parameter configurations.
A &#39;sample&#39; represents a node or data point in a Markov Chain.
Definition: sample.hpp:31