gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-252-gf9a3f78
a Global And Modular Bsm Inference Tool
gaussian.hpp
Go to the documentation of this file.
1 // GAMBIT: Global and Modular BSM Inference Tool
2 // *********************************************
24 
25 #ifndef __PRIOR_GAUSSIAN_HPP__
26 #define __PRIOR_GAUSSIAN_HPP__
27 
28 #include <algorithm>
29 #include <cmath>
30 #include <string>
31 #include <unordered_map>
32 #include <vector>
33 
37 
38 #include <boost/math/special_functions/erf.hpp>
39 
40 namespace Gambit
41 {
42  namespace Priors
43  {
52  class Gaussian : public BasePrior
53  {
54  private:
55  std::vector <double> mu;
56  mutable Cholesky col;
57 
58  public:
59  // Constructor defined in gaussian.cpp
60  Gaussian(const std::vector<std::string>&, const Options&);
61 
62  // Transformation from unit interval to the Gaussian
63  void transform(const std::vector <double> &unitpars, std::unordered_map<std::string, double> &outputMap) const
64  {
65  std::vector<double> vec(unitpars.size());
66 
67  auto v_it = vec.begin();
68  for (auto elem_it = unitpars.begin(), elem_end = unitpars.end(); elem_it != elem_end; elem_it++, v_it++)
69  {
70  *v_it = M_SQRT2 * boost::math::erf_inv(2. * (*elem_it) - 1.);
71  }
72 
73  col.ElMult(vec);
74 
75  v_it = vec.begin();
76  auto m_it = mu.begin();
77  for (auto str_it = param_names.begin(), str_end = param_names.end(); str_it != str_end; str_it++)
78  {
79  outputMap[*str_it] = *(v_it++) + *(m_it++);
80  }
81  }
82 
83  double operator()(const std::vector<double> &vec) const
84  {
85  static double norm = 0.5 * std::log(2. * M_PI * std::pow(col.DetSqrt(), 2));
86  return -0.5 * col.Square(vec, mu) - norm;
87  }
88  };
89 
90  LOAD_PRIOR(gaussian, Gaussian)
91 
92  } // namespace Priors
93 } // namespace Gambit
94 
95 #endif // __PRIOR_GAUSSIAN_HPP__
Abstract base class for priors.
Definition: base_prior.hpp:40
declaration for scanner module
std::vector< double > mu
Definition: gaussian.hpp:55
double operator()(const std::vector< double > &vec) const
Log of PDF density.
Definition: gaussian.hpp:83
std::vector< std::string > param_names
Definition: base_prior.hpp:46
double Square(const std::vector< double > &y, const std::vector< double > &y0)
Definition: cholesky.hpp:86
Prior object construction routines.
Declarations for the YAML options class.
Multi-dimensional Gaussian prior.
Definition: gaussian.hpp:52
double DetSqrt()
Definition: cholesky.hpp:107
void transform(const std::vector< double > &unitpars, std::unordered_map< std::string, double > &outputMap) const
Transform from unit hypercube to parameter.
Definition: gaussian.hpp:63
RangePrior1D< flatprior > LOAD_PRIOR(cos, RangePrior1D< cosprior >) LOAD_PRIOR(sin
double pow(const double &a)
Outputs a^i.
void ElMult(std::vector< double > &y) const
Definition: cholesky.hpp:69
std::vector< T > vec(std::vector< T > vector)
Definition: daFunk.hpp:142
TODO: see if we can use this one:
Definition: Analysis.hpp:33
A small wrapper object for &#39;options&#39; nodes.
Gaussian(const std::vector< std::string > &, const Options &)
Definition: gaussian.cpp:31