BCPositiveDefinitePrior.h
1 #ifndef __BCPOSITIVEDEFINITEPRIOR__H
2 #define __BCPOSITIVEDEFINITEPRIOR__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 <algorithm>
25 #include <limits>
26 
27 #include "BCPrior.h"
28 
29 class TRandom;
30 
31 // ---------------------------------------------------------
32 
34 {
35 public:
36 
43 
47 
50  virtual ~BCPositiveDefinitePrior();
51 
59 
62 
68  BCPrior* Prior()
69  { return fPrior; }
70 
71  const BCPrior* Prior() const
72  { return fPrior; }
73 
83  virtual double GetLogPrior(double x)
84  { return (x >= 0 and fPrior) ? fPrior->GetLogPrior(x) : -std::numeric_limits<double>::infinity(); }
85 
91  virtual double GetPrior(double x, bool normalize = false)
92  { return (x >= 0 and fPrior) ? fPrior->GetPrior(x, normalize) : 0; }
93 
96  virtual BCPrior* Clone() const
97  { return new BCPositiveDefinitePrior(*this); }
98 
101  virtual bool IsValid() const
102  { return fPrior != NULL and fPrior->IsValid(); }
103 
105  virtual void SetFunctionRange(double xmin, double xmax)
106  { BCPrior::SetFunctionRange(xmin, xmax); if (fPrior) fPrior->SetFunctionRange(xmin, xmax); }
107 
113  virtual double GetMode(double xmin = -std::numeric_limits<double>::infinity(), double xmax = std::numeric_limits<double>::infinity())
114  { return (fPrior) ? fPrior->GetMode(std::max<double>(xmin, 0), std::max<double>(xmax, 0)) : std::numeric_limits<double>::quiet_NaN(); }
115 
122  virtual double GetRawMoment(unsigned n, double xmin = -std::numeric_limits<double>::infinity(), double xmax = std::numeric_limits<double>::infinity())
123  { return (fPrior) ? fPrior->GetRawMoment(n, std::max<double>(xmin, 0), std::max<double>(xmax, 0)) : std::numeric_limits<double>::quiet_NaN(); }
124 
130  virtual double GetIntegral(double xmin = -std::numeric_limits<double>::infinity(), double xmax = std::numeric_limits<double>::infinity())
131  { return (fPrior) ? fPrior->GetIntegral(std::max<double>(xmin, 0), std::max<double>(xmax, 0)) : std::numeric_limits<double>::quiet_NaN(); }
132 
139  virtual double GetCentralMoment(unsigned n, double xmin = -std::numeric_limits<double>::infinity(), double xmax = std::numeric_limits<double>::infinity())
140  { return (fPrior) ? fPrior->GetCentralMoment(n, std::max<double>(xmin, 0), std::max<double>(xmax, 0)) : std::numeric_limits<double>::quiet_NaN(); }
141 
148  virtual double GetStandardizedMoment(unsigned n, double xmin = -std::numeric_limits<double>::infinity(), double xmax = std::numeric_limits<double>::infinity())
149  { return (fPrior) ? fPrior->GetCentralMoment(n, std::max<double>(xmin, 0), std::max<double>(xmax, 0)) : std::numeric_limits<double>::quiet_NaN(); }
150 
156  virtual double GetMean(double xmin = -std::numeric_limits<double>::infinity(), double xmax = std::numeric_limits<double>::infinity())
157  { return (fPrior) ? fPrior->GetMean(std::max<double>(xmin, 0), std::max<double>(xmax, 0)) : std::numeric_limits<double>::quiet_NaN(); }
158 
164  virtual double GetVariance(double xmin = -std::numeric_limits<double>::infinity(), double xmax = std::numeric_limits<double>::infinity())
165  { return (fPrior) ? fPrior->GetVariance(std::max<double>(xmin, 0), std::max<double>(xmax, 0)) : std::numeric_limits<double>::quiet_NaN(); }
166 
172  virtual double GetStandardDeviation(double xmin = -std::numeric_limits<double>::infinity(), double xmax = std::numeric_limits<double>::infinity())
173  { return (fPrior) ? fPrior->GetStandardDeviation(std::max<double>(xmin, 0), std::max<double>(xmax, 0)) : std::numeric_limits<double>::quiet_NaN(); }
174 
180  virtual double GetSkewness(double xmin = -std::numeric_limits<double>::infinity(), double xmax = std::numeric_limits<double>::infinity())
181  { return (fPrior) ? fPrior->GetSkewness(std::max<double>(xmin, 0), std::max<double>(xmax, 0)) : std::numeric_limits<double>::quiet_NaN(); }
182 
188  virtual double GetKurtosis(double xmin = -std::numeric_limits<double>::infinity(), double xmax = std::numeric_limits<double>::infinity())
189  { return (fPrior) ? fPrior->GetKurtosis(std::max<double>(xmin, 0), std::max<double>(xmax, 0)) : std::numeric_limits<double>::quiet_NaN(); }
190 
197  virtual double GetRandomValue(double xmin, double xmax, TRandom* const R = NULL);
198 
201 protected:
202 
205 
206 };
207 
208 #endif
virtual double GetKurtosis(double xmin=-std::numeric_limits< double >::infinity(), double xmax=std::numeric_limits< double >::infinity())
Get kurtosis of prior.
A class to represent the prior of a parameter.
Definition: BCPrior.h:49
virtual double GetKurtosis(double xmin=-std::numeric_limits< double >::infinity(), double xmax=std::numeric_limits< double >::infinity())
Get kurtosis of prior.
Definition: BCPrior.h:205
virtual double GetPrior(double x, bool normalize=false)
Get prior.
virtual double GetIntegral(double xmin=-std::numeric_limits< double >::infinity(), double xmax=std::numeric_limits< double >::infinity())
Get integral of prior.
virtual void SetFunctionRange(double xmin, double xmax)
Set range of ROOT TF1 function.
Definition: BCPrior.cxx:133
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.
BCPositiveDefinitePrior(BCPrior *prior)
Constructor.
virtual double GetSkewness(double xmin=-std::numeric_limits< double >::infinity(), double xmax=std::numeric_limits< double >::infinity())
Get skewness of prior.
BCPrior * fPrior
Prior that is cut to positive values.
virtual double GetMean(double xmin=-std::numeric_limits< double >::infinity(), double xmax=std::numeric_limits< double >::infinity())
Get mean of prior.
virtual double GetCentralMoment(unsigned n, double xmin=-std::numeric_limits< double >::infinity(), double xmax=std::numeric_limits< double >::infinity())
Get central moment of prior distrubion.
virtual double GetMode(double xmin=-std::numeric_limits< double >::infinity(), double xmax=std::numeric_limits< double >::infinity())
Return mode of prior (in range).
virtual double GetMode(double xmin=-std::numeric_limits< double >::infinity(), double xmax=std::numeric_limits< double >::infinity())
Return mode of prior (in range).
Definition: BCPrior.cxx:65
virtual bool IsValid() const
virtual double GetStandardDeviation(double xmin=-std::numeric_limits< double >::infinity(), double xmax=std::numeric_limits< double >::infinity())
Get standard deviation of prior.
Definition: BCPrior.h:189
BCPositiveDefinitePrior & operator=(BCPositiveDefinitePrior other)
assignment operator
virtual BCPrior * Clone() const
Clone function.
virtual double GetVariance(double xmin=-std::numeric_limits< double >::infinity(), double xmax=std::numeric_limits< double >::infinity())
Get variance of prior.
virtual double GetSkewness(double xmin=-std::numeric_limits< double >::infinity(), double xmax=std::numeric_limits< double >::infinity())
Get skewness of prior.
Definition: BCPrior.h:197
virtual double GetLogPrior(double x)
Get log of prior.
A class to wrap around a BCPrior to make it positive definite.
virtual void SetFunctionRange(double xmin, double xmax)
Set ROOT function range.
virtual double GetIntegral(double xmin=-std::numeric_limits< double >::infinity(), double xmax=std::numeric_limits< double >::infinity())
Get integral of prior.
Definition: BCPrior.cxx:81
friend void swap(BCPositiveDefinitePrior &A, BCPositiveDefinitePrior &B)
swap
virtual double GetStandardizedMoment(unsigned n, double xmin=-std::numeric_limits< double >::infinity(), double xmax=std::numeric_limits< double >::infinity())
Get standardised moment of prior distrubion.
virtual double GetMean(double xmin=-std::numeric_limits< double >::infinity(), double xmax=std::numeric_limits< double >::infinity())
Get mean of prior.
Definition: BCPrior.h:173
virtual double GetCentralMoment(unsigned n, double xmin=-std::numeric_limits< double >::infinity(), double xmax=std::numeric_limits< double >::infinity())
Get central moment of prior distrubion.
Definition: BCPrior.cxx:88
virtual double GetStandardDeviation(double xmin=-std::numeric_limits< double >::infinity(), double xmax=std::numeric_limits< double >::infinity())
Get standard deviation of prior.
virtual double GetVariance(double xmin=-std::numeric_limits< double >::infinity(), double xmax=std::numeric_limits< double >::infinity())
Get variance of prior.
Definition: BCPrior.h:181
virtual double GetRandomValue(double xmin, double xmax, TRandom *const R=NULL)
virtual bool IsValid() const =0
virtual ~BCPositiveDefinitePrior()
Destructor.
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.
Definition: BCPrior.cxx:72