BCSplitGaussianPrior.h
1 #ifndef __BCSPLITGAUSSIANPRIOR__H
2 #define __BCSPLITGAUSSIANPRIOR__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 
33 {
34 public:
39  BCSplitGaussianPrior(double mode, double sigma_below, double sigma_above);
40 
43 
45  virtual ~BCSplitGaussianPrior() {};
46 
53  virtual BCPrior* Clone() const
54  { return new BCSplitGaussianPrior(*this); }
55 
58  virtual bool IsValid() const
59  {
60  return std::isfinite(fMode)
61  and std::isfinite(fSigmaBelow) and fSigmaBelow > 0
62  and std::isfinite(fSigmaAbove) and fSigmaAbove > 0;
63  }
64 
69  virtual double GetLogPrior(double x);
70 
76  virtual double GetMode(double xmin = -std::numeric_limits<double>::infinity(), double xmax = std::numeric_limits<double>::infinity())
77  { if (fMode < xmin) return xmin; if (fMode > xmax) return xmax; return fMode; }
78 
85  virtual double GetRawMoment(unsigned n, double xmin = -std::numeric_limits<double>::infinity(), double xmax = std::numeric_limits<double>::infinity());
86 
92  virtual double GetIntegral(double xmin = -std::numeric_limits<double>::infinity(), double xmax = std::numeric_limits<double>::infinity());
93 
99  void SetMean(double mean)
100  { SetMode(mean); }
101 
102  void SetMode(double mode)
103  { fMode = mode; }
104 
105  void SetSigmaBelow(double sigma)
106  { fSigmaBelow = sigma; }
107 
108  void SetSigmaAbove(double sigma)
109  { fSigmaAbove = sigma; }
110 
111  void SetParameters(double mode, double sigma_below, double sigma_above)
112  { SetMode(mode); SetSigmaBelow(sigma_below); SetSigmaAbove(sigma_above);}
113 
116 protected:
117  double fMode;
118  double fSigmaBelow;
119  double fSigmaAbove;
120 };
121 
122 #endif
virtual double GetLogPrior(double x)
Get log of prior.
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.
virtual double GetIntegral(double xmin=-std::numeric_limits< double >::infinity(), double xmax=std::numeric_limits< double >::infinity())
Get integral of prior.
double fSigmaBelow
std dev of split gaussian below mode
A class to represent the prior of a parameter.
Definition: BCPrior.h:49
double fSigmaAbove
std dev of split gaussian above mode
virtual double GetMode(double xmin=-std::numeric_limits< double >::infinity(), double xmax=std::numeric_limits< double >::infinity())
Return mode of prior (in range).
A class to represent a split-Gaussian prior of a parameter.
virtual ~BCSplitGaussianPrior()
Destructor.
virtual bool IsValid() const
virtual BCPrior * Clone() const
Clone function.
BCSplitGaussianPrior(double mode, double sigma_below, double sigma_above)
Constructor.