gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-2191-ga4742ac
a Global And Modular Bsm Inference Tool
base_prior.hpp
Go to the documentation of this file.
1 // GAMBIT: Global and Modular BSM Inference Tool
2 // *********************************************
24 
25 #ifndef __BASE_PRIORS_HPP__
26 #define __BASE_PRIORS_HPP__
27 
28 #include <string>
29 #include <unordered_map>
30 #include <vector>
31 
32 
33 namespace Gambit
34 {
35  namespace Priors
36  {
40  class BasePrior
41  {
42  private:
43  unsigned int param_size;
44 
45  protected:
46  std::vector<std::string> param_names;
47 
48  public:
49  virtual ~BasePrior() = default;
50 
51  BasePrior() : param_size(0), param_names(0) {}
52 
53  explicit BasePrior(const int param_size) :
54  param_size(param_size), param_names(0) {}
55 
56  explicit BasePrior(const std::vector<std::string> &param_names, const int param_size = 0) :
57  param_size(param_size), param_names(param_names) {}
58 
59  explicit BasePrior(const std::string &param_name, const int param_size = 0) :
60  param_size(param_size), param_names(1, param_name) {}
61 
63  virtual void transform(const std::vector<double> &, std::unordered_map<std::string, double> &) const = 0;
64 
66  virtual std::vector<double> inverse_transform(const std::unordered_map<std::string, double> &) const = 0;
67 
69  virtual double operator()(const std::vector<double> &) const
70  {
71  Scanner::scan_error().raise(LOCAL_INFO, "operator() not implemented");
72  return 0.;
73  }
74 
75  virtual std::vector<std::string> getShownParameters() const { return param_names; }
76 
77  inline unsigned int size() const { return param_size; }
78 
79  inline void setSize(const unsigned int size) { param_size = size; }
80 
81  inline unsigned int & sizeRef() { return param_size; }
82 
83  inline std::vector<std::string> getParameters() const { return param_names; }
84  };
85 
86  } // namespace Priors
87 } // namespace Gambit
88 
89 #endif // __BASE_PRIORS_HPP__
Abstract base class for priors.
Definition: base_prior.hpp:40
virtual std::vector< double > inverse_transform(const std::unordered_map< std::string, double > &) const =0
Transform from parameter back to unit hypercube.
void setSize(const unsigned int size)
Definition: base_prior.hpp:79
BasePrior(const std::vector< std::string > &param_names, const int param_size=0)
Definition: base_prior.hpp:56
std::vector< std::string > param_names
Definition: base_prior.hpp:46
#define LOCAL_INFO
Definition: local_info.hpp:34
unsigned int size() const
Definition: base_prior.hpp:77
virtual ~BasePrior()=default
virtual std::vector< std::string > getShownParameters() const
Definition: base_prior.hpp:75
BasePrior(const int param_size)
Definition: base_prior.hpp:53
EXPORT_SYMBOLS error & scan_error()
Scanner errors.
std::vector< std::string > getParameters() const
Definition: base_prior.hpp:83
virtual void transform(const std::vector< double > &, std::unordered_map< std::string, double > &) const =0
Transform from unit hypercube to parameter.
unsigned int & sizeRef()
Definition: base_prior.hpp:81
BasePrior(const std::string &param_name, const int param_size=0)
Definition: base_prior.hpp:59
TODO: see if we can use this one:
Definition: Analysis.hpp:33
virtual double operator()(const std::vector< double > &) const
Log of PDF density.
Definition: base_prior.hpp:69