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