BCCauchyPrior.h
1 #ifndef __BCCAUCHYPRIOR__H
2 #define __BCCAUCHYPRIOR__H
3 
14 /*
15  * Copyright (C) 2007-2018, the BAT core developer team
16  * All rights reserved.
17  *
18  * For the licensing terms see doc/COPYING.
19  * For documentation see http://mpp.mpg.de/bat
20  */
21 
22 // ---------------------------------------------------------
23 
24 #include "BCPrior.h"
25 
26 #include <limits>
27 
28 class TF1;
29 
30 // ---------------------------------------------------------
31 
32 class BCCauchyPrior : public BCPrior
33 {
34 public:
39  BCCauchyPrior(double mean, double scale);
40 
42  virtual ~BCCauchyPrior() {};
43 
50  virtual BCPrior* Clone() const
51  { return new BCCauchyPrior(*this); }
52 
55  virtual bool IsValid() const
56  { return std::isfinite(fMean) and std::isfinite(fScale) and fScale > 0;}
57 
62  virtual double GetLogPrior(double x)
63  { return log(fScale) - log(fScale * fScale + (x - fMean) * (x - fMean)) - log(M_PI); }
64 
70  virtual double GetMode(double xmin = -std::numeric_limits<double>::infinity(), double xmax = std::numeric_limits<double>::infinity())
71  { if (fMean < xmin) return xmin; if (fMean > xmax) return xmax; return fMean; }
72 
79  virtual double GetRawMoment(unsigned n, double xmin = -std::numeric_limits<double>::infinity(), double xmax = std::numeric_limits<double>::infinity());
80 
86  virtual double GetIntegral(double xmin = -std::numeric_limits<double>::infinity(), double xmax = std::numeric_limits<double>::infinity());
87 
88  virtual double GetScale() const
89  { return fScale; }
90 
96  virtual void SetMean(double mean)
97  { fMean = mean; }
98 
99  virtual void SetScale(double scale)
100  { fScale = scale; }
101 
102  virtual void SetParameters(double mean, double scale)
103  { SetMean(mean); SetScale(scale); }
104 
107 protected:
108  double fMean;
109  double fScale;
110 };
111 
112 #endif
A class to represent the prior of a parameter.
Definition: BCPrior.h:49
virtual double GetIntegral(double xmin=-std::numeric_limits< double >::infinity(), double xmax=std::numeric_limits< double >::infinity())
Get integral of prior.
A class to represent a Cauchy prior of a parameter.
Definition: BCCauchyPrior.h:32
virtual double GetMode(double xmin=-std::numeric_limits< double >::infinity(), double xmax=std::numeric_limits< double >::infinity())
Return mode of prior (in range).
Definition: BCCauchyPrior.h:70
BCCauchyPrior(double mean, double scale)
Constructor.
virtual BCPrior * Clone() const
Clone function.
Definition: BCCauchyPrior.h:50
virtual bool IsValid() const
Definition: BCCauchyPrior.h:55
virtual ~BCCauchyPrior()
Destrcutor.
Definition: BCCauchyPrior.h:42
virtual double GetLogPrior(double x)
Get log of prior.
Definition: BCCauchyPrior.h:62
virtual double GetRawMoment(unsigned n, double xmin=-std::numeric_limits< double >::infinity(), double xmax=std::numeric_limits< double >::infinity())
Get raw moment of prior distrubion.
double fScale
scale of Cauchy distribution