BAT  0.9.4
The Bayesian analysis toolkit
 All Classes Namespaces Functions Variables Enumerations
BCModel Class Referenceabstract

The base class for all user-defined models. More...

#include <BCModel.h>

Inheritance diagram for BCModel:
Collaboration diagram for BCModel:

Public Member Functions

Constructors and destructors
 BCModel (const char *name="model")
 
 BCModel (const BCModel &bcmodel)
 
virtual ~BCModel ()
 
Assignment operators
BCModeloperator= (const BCModel &bcmodel)
 
Member functions (get)
const std::string & GetName () const
 
double GetModelAPrioriProbability () const
 
double GetModelAPosterioriProbability () const
 
BCDataSetGetDataSet () const
 
BCDataPointGetDataPointLowerBoundaries () const
 
BCDataPointGetDataPointUpperBoundaries () const
 
double GetDataPointLowerBoundary (unsigned int index) const
 
double GetDataPointUpperBoundary (unsigned int index) const
 
bool GetFlagBoundaries () const
 
unsigned GetNDataPoints () const
 
BCDataPointGetDataPoint (unsigned int index) const
 
Member functions (set)
void SetName (const char *name)
 
void SetModelAPrioriProbability (double probability)
 
void SetModelAPosterioriProbability (double probability)
 
virtual int AddParameter (BCParameter *parameter)
 
void SetDataSet (BCDataSet *dataset)
 
void SetSingleDataPoint (BCDataPoint *datapoint)
 
void SetSingleDataPoint (BCDataSet *dataset, unsigned int index)
 
void SetDataBoundaries (unsigned int index, double lowerboundary, double upperboundary, bool fixed=false)
 
void SetDataPointLowerBoundaries (BCDataPoint *datasetlowerboundaries)
 
void SetDataPointUpperBoundaries (BCDataPoint *datasetupperboundaries)
 
void SetDataPointLowerBoundary (int index, double lowerboundary)
 
void SetDataPointUpperBoundary (int index, double upperboundary)
 
int SetPrior (int index, TF1 *f)
 
int SetPrior (const char *name, TF1 *f)
 
int SetPriorDelta (int index, double value)
 
int SetPriorDelta (const char *name, double value)
 
int SetPriorGauss (int index, double mean, double sigma)
 
int SetPriorGauss (const char *name, double mean, double sigma)
 
int SetPriorGauss (int index, double mean, double sigmadown, double sigmaup)
 
int SetPriorGauss (const char *name, double mean, double sigmadown, double sigmaup)
 
int SetPrior (int index, TH1 *h, bool flag=false)
 
int SetPrior (const char *name, TH1 *h, bool flag=false)
 
int SetPriorConstant (int index)
 
int SetPriorConstant (const char *name)
 
int SetPriorConstantAll ()
 
Member functions (miscellaneous methods)
void Copy (const BCModel &bcmodel)
 
double APrioriProbability (const std::vector< double > &parameters)
 
virtual double LogAPrioriProbability (const std::vector< double > &parameters)
 
virtual double Likelihood (const std::vector< double > &params)
 
virtual double LogLikelihood (const std::vector< double > &params)=0
 
double ProbabilityNN (const std::vector< double > &params)
 
double LogProbabilityNN (const std::vector< double > &parameters)
 
double Probability (const std::vector< double > &parameter)
 
double LogProbability (const std::vector< double > &parameter)
 
virtual double SamplingFunction (const std::vector< double > &parameters)
 
double Eval (const std::vector< double > &parameters)
 
virtual double LogEval (const std::vector< double > &parameters)
 
virtual void CorrelateDataPointValues (std::vector< double > &x)
 
double GetPvalueFromChi2 (const std::vector< double > &par, int sigma_index)
 
double GetPvalueFromKolmogorov (const std::vector< double > &par, int index)
 
double GetPvalueFromChi2NDoF (std::vector< double > par, int sigma_index)
 
BCH1DCalculatePValue (std::vector< double > par, bool flag_histogram=false)
 
double GetPValue ()
 
double GetPValueNDoF ()
 
double GetChi2NDoF ()
 
std::vector< double > GetChi2Runs (int dataIndex, int sigmaIndex)
 
void SetGoFNIterationsMax (int n)
 
void SetGoFNIterationsRun (int n)
 
void SetGoFNChains (int n)
 
double HessianMatrixElement (const BCParameter *parameter1, const BCParameter *parameter2, std::vector< double > point)
 
void PrintSummary ()
 
void PrintResults (const char *file)
 
void PrintShortFitSummary (int chi2flag=0)
 
void PrintHessianMatrix (std::vector< double > parameters)
 
virtual double CDF (const std::vector< double > &, int, bool)
 

Protected Attributes

std::string fName
 
double fModelAPriori
 
double fModelAPosteriori
 
BCDataSetfDataSet
 
BCDataPointfDataPointLowerBoundaries
 
BCDataPointfDataPointUpperBoundaries
 
std::vector< bool > fDataFixedValues
 
double fPValue
 
double fChi2NDoF
 
double fPValueNDoF
 
bool flag_discrete
 
int fGoFNIterationsMax
 
int fGoFNIterationsRun
 
int fGoFNChains
 
std::vector< TNamed * > fPriorContainer
 
bool fPriorConstantAll
 
std::vector< bool > fPriorContainerConstant
 
std::vector< bool > fPriorContainerInterpolate
 

Detailed Description

The base class for all user-defined models.

Author
Daniel Kollar
Kevin Kröninger
Version
1.0
Date
08.2008 This class represents a model. It contains a container of prior distributions and the likelihood. The methods that implement the prior and the likelihood have to be overloaded by the user in the user defined model class derived from this class.

Definition at line 50 of file BCModel.h.

Constructor & Destructor Documentation

BCModel::BCModel ( const char *  name = "model")

A constructor.

Parameters
nameThe name of the model

Definition at line 36 of file BCModel.cxx.

BCModel::BCModel ( const BCModel bcmodel)

The copy constructor.

Definition at line 56 of file BCModel.cxx.

BCModel::~BCModel ( )
virtual

The default destructor.

Definition at line 104 of file BCModel.cxx.

Member Function Documentation

int BCModel::AddParameter ( BCParameter parameter)
virtual

Adds a parameter to the model.

Parameters
parameterA model parameter
See Also
AddParameter(const char * name, double lowerlimit, double upperlimit);

Definition at line 225 of file BCModel.cxx.

double BCModel::APrioriProbability ( const std::vector< double > &  parameters)

Returns the prior probability.

Parameters
parametersA set of parameter values
Returns
The prior probability p(parameters)
See Also
GetPrior(std::vector<double> parameters)

Definition at line 267 of file BCModel.cxx.

virtual double BCModel::CDF ( const std::vector< double > &  ,
int  ,
bool   
)
inlinevirtual

1dim cumulative distribution function of the probability to get the data f(x_i|param) for a single measurement, assumed to be of identical functional form for all measurements

Parameters
parametersThe parameter values at which point to compute the cdf
indexThe data point index starting at 0,1...N-1
loweronly needed for discrete distributions! Return the CDF for the count one less than actually observed, e.g. in Poisson process, if 3 actually observed, then CDF(2) is returned

Reimplemented in BCHistogramFitter, and BCGraphFitter.

Definition at line 502 of file BCModel.h.

void BCModel::Copy ( const BCModel bcmodel)

Copy from object

Parameters
bcmodelObject to copy from.

Definition at line 62 of file BCModel.cxx.

void BCModel::CorrelateDataPointValues ( std::vector< double > &  x)
virtual

Constrains a data point

Parameters
xA vector of double

Definition at line 495 of file BCModel.cxx.

double BCModel::Eval ( const std::vector< double > &  parameters)

Overloaded function to evaluate integral.

Definition at line 330 of file BCModel.cxx.

std::vector< double > BCModel::GetChi2Runs ( int  dataIndex,
int  sigmaIndex 
)

For a Gaussian problem, calculate the chi2 of the longest run of consecutive values above/below the expected values

Parameters
dataIndexcomponent of datapoint with the observed value
sigmaIndexcomponent of datapoint with uncertainty

Definition at line 368 of file BCModel.cxx.

BCDataPoint * BCModel::GetDataPoint ( unsigned int  index) const
Parameters
indexThe index of the data point.
Returns
The data point in the current data set at index

Definition at line 132 of file BCModel.cxx.

BCDataPoint* BCModel::GetDataPointLowerBoundaries ( ) const
inline
Returns
The lower boundaries of possible data values.

Definition at line 105 of file BCModel.h.

double BCModel::GetDataPointLowerBoundary ( unsigned int  index) const
Parameters
indexThe index of the variable.
Returns
The lower boundary of possible data values for a particular variable.

Definition at line 142 of file BCModel.cxx.

BCDataPoint* BCModel::GetDataPointUpperBoundaries ( ) const
inline
Returns
The upper boundaries of possible data values.

Definition at line 110 of file BCModel.h.

double BCModel::GetDataPointUpperBoundary ( unsigned int  index) const
Parameters
indexThe index of the variable.
Returns
The upper boundary of possible data values for a particular variable.

Definition at line 148 of file BCModel.cxx.

BCDataSet* BCModel::GetDataSet ( ) const
inline
Returns
The data set.

Definition at line 100 of file BCModel.h.

bool BCModel::GetFlagBoundaries ( ) const

Checks if the boundaries have been defined

Returns
true, if the boundaries have been set, false otherwise

Definition at line 154 of file BCModel.cxx.

double BCModel::GetModelAPosterioriProbability ( ) const
inline
Returns
The a posteriori probability.

Definition at line 95 of file BCModel.h.

double BCModel::GetModelAPrioriProbability ( ) const
inline
Returns
The a priori probability.

Definition at line 90 of file BCModel.h.

const std::string& BCModel::GetName ( ) const
inline
Returns
The name of the model.

Definition at line 85 of file BCModel.h.

unsigned BCModel::GetNDataPoints ( ) const
Returns
The number of data points in the current data set.

Definition at line 123 of file BCModel.cxx.

double BCModel::GetPValue ( )
inline
Returns
The p-value

Definition at line 435 of file BCModel.h.

double BCModel::GetPvalueFromChi2 ( const std::vector< double > &  par,
int  sigma_index 
)

Calculate p-value from Chi2 distribution for Gaussian problems

Parameters
parParameter set for the calculation of the likelihood
sigma_indexIndex of the sigma/uncertainty for the data points (for data in format "x y erry" the index would be 2)

Definition at line 351 of file BCModel.cxx.

double BCModel::GetPvalueFromKolmogorov ( const std::vector< double > &  par,
int  index 
)

Calculate p-value from Kolmogorov-Smirnov test statistic for 1D - datasets.

Parameters
parParameter set for the calculation of the likelihood
indexIndex of the data point in the BCDataSet (for data in format "x y erry" the index would be 1)

Definition at line 394 of file BCModel.cxx.

double BCModel::HessianMatrixElement ( const BCParameter parameter1,
const BCParameter parameter2,
std::vector< double >  point 
)

Calculates the matrix element of the Hessian matrix

Parameters
parameter1The parameter for the first derivative
parameter2The parameter for the first derivative
Returns
The matrix element of the Hessian matrix

Definition at line 501 of file BCModel.cxx.

double BCModel::Likelihood ( const std::vector< double > &  params)
virtual

Returns the likelihood

Parameters
paramsA set of parameter values
Returns
The likelihood

Definition at line 324 of file BCModel.cxx.

double BCModel::LogAPrioriProbability ( const std::vector< double > &  parameters)
virtual

Returns natural logarithm of the prior probability. Method needs to be overloaded by the user.

Parameters
parametersA set of parameter values
Returns
The prior probability p(parameters)
See Also
GetPrior(std::vector<double> parameters)

Reimplemented in BCGoFTest, BCMVCDataModel, BCSummaryPriorModel, and BCRooInterface.

Definition at line 273 of file BCModel.cxx.

double BCModel::LogEval ( const std::vector< double > &  parameters)
virtual

Overloaded function to evaluate integral.

Definition at line 336 of file BCModel.cxx.

virtual double BCModel::LogLikelihood ( const std::vector< double > &  params)
pure virtual

Calculates natural logarithm of the likelihood. Method needs to be overloaded by the user.

Parameters
paramsA set of parameter values
Returns
Natural logarithm of the likelihood

Implemented in BCMTF, BCEfficiencyFitter, BCMVCombination, BCHistogramFitter, BCGraphFitter, BCGoFTest, BCMVCDataModel, BCSummaryPriorModel, BCMVCPhysicsModel, and BCRooInterface.

double BCModel::LogProbability ( const std::vector< double > &  parameter)

Returns natural logarithm of the a posteriori probability given a set of parameter values

Parameters
parametersA set of parameter values
Returns
The a posteriori probability

Definition at line 255 of file BCModel.cxx.

double BCModel::LogProbabilityNN ( const std::vector< double > &  parameters)
inline

Returns the natural logarithm of likelihood times prior probability given a set of parameter values

Parameters
parametersA set of parameter values
Returns
The likelihood times prior probability

Definition at line 378 of file BCModel.h.

BCModel & BCModel::operator= ( const BCModel bcmodel)

Defaut assignment operator

Definition at line 115 of file BCModel.cxx.

void BCModel::PrintHessianMatrix ( std::vector< double >  parameters)

Prints matrix elements of the Hessian matrix

Parameters
parametersThe parameter values at which point to evaluate the matrix

Definition at line 1056 of file BCModel.cxx.

void BCModel::PrintResults ( const char *  file)

Prints a summary of the Markov Chain Monte Carlo to a file.

Definition at line 816 of file BCModel.cxx.

void BCModel::PrintShortFitSummary ( int  chi2flag = 0)

Prints a short summary of the fit results on the screen.

Definition at line 1029 of file BCModel.cxx.

void BCModel::PrintSummary ( )

Prints a summary on the screen.

Definition at line 772 of file BCModel.cxx.

double BCModel::Probability ( const std::vector< double > &  parameter)

Returns the a posteriori probability given a set of parameter values

Parameters
parametersA set of parameter values
Returns
The a posteriori probability

Definition at line 249 of file BCModel.cxx.

double BCModel::ProbabilityNN ( const std::vector< double > &  params)

Returns the likelihood times prior probability given a set of parameter values

Parameters
paramsA set of parameter values
Returns
The likelihood times prior probability

Definition at line 243 of file BCModel.cxx.

double BCModel::SamplingFunction ( const std::vector< double > &  parameters)
virtual

Sampling function used for importance sampling. Method needs to be overloaded by the user.

Parameters
parametersA set of parameter values
Returns
The probability density at the parameter values

Definition at line 342 of file BCModel.cxx.

void BCModel::SetDataPointLowerBoundaries ( BCDataPoint datasetlowerboundaries)
inline

Sets the data point containing the lower boundaries of possible data values

Definition at line 193 of file BCModel.h.

void BCModel::SetDataPointLowerBoundary ( int  index,
double  lowerboundary 
)

Sets the lower boundary of possible data values for a particular variable

Definition at line 546 of file BCModel.cxx.

void BCModel::SetDataPointUpperBoundaries ( BCDataPoint datasetupperboundaries)
inline

Sets the data point containing the upper boundaries of possible data values

Definition at line 199 of file BCModel.h.

void BCModel::SetDataPointUpperBoundary ( int  index,
double  upperboundary 
)

Sets the upper boundary of possible data values for a particular variable

Definition at line 552 of file BCModel.cxx.

void BCModel::SetDataSet ( BCDataSet dataset)
inline

Sets the data set.

Parameters
datasetA data set

Definition at line 178 of file BCModel.h.

void BCModel::SetGoFNChains ( int  n)
inline

Set number of chains in the MCMC of the p-value evaluation using MCMC

Definition at line 466 of file BCModel.h.

void BCModel::SetGoFNIterationsMax ( int  n)
inline

Set maximum number of iterations in the MCMC pre-run of the p-value evaluation using MCMC

Definition at line 454 of file BCModel.h.

void BCModel::SetGoFNIterationsRun ( int  n)
inline

Set number of iterations in the MCMC normal run of the p-value evaluation using MCMC

Definition at line 460 of file BCModel.h.

void BCModel::SetModelAPosterioriProbability ( double  probability)
inline

Sets the a posteriori probability for a model.

Parameters
modelThe model
probabilityThe a posteriori probability

Definition at line 159 of file BCModel.h.

void BCModel::SetModelAPrioriProbability ( double  probability)
inline

Sets the a priori probability for a model.

Parameters
modelThe model
probabilityThe a priori probability

Definition at line 152 of file BCModel.h.

void BCModel::SetName ( const char *  name)
inline

Sets the name of the model.

Parameters
nameName of the model

Definition at line 145 of file BCModel.h.

int BCModel::SetPrior ( int  index,
TF1 *  f 
)

Set prior for a parameter.

Parameters
indexThe parameter index
fA pointer to a function describing the prior
Returns
An error code.

Definition at line 558 of file BCModel.cxx.

int BCModel::SetPrior ( const char *  name,
TF1 *  f 
)

Set prior for a parameter.

Parameters
nameThe parameter name
fA pointer to a function describing the prior
Returns
An error code.

Definition at line 579 of file BCModel.cxx.

int BCModel::SetPrior ( int  index,
TH1 *  h,
bool  flag = false 
)

Set prior for a parameter.

Parameters
indexparameter index
hpointer to a histogram describing the prior
flagwhether or not to use linear interpolation
Returns
An error code.

Definition at line 682 of file BCModel.cxx.

int BCModel::SetPrior ( const char *  name,
TH1 *  h,
bool  flag = false 
)

Set prior for a parameter.

Parameters
nameparameter name
hpointer to a histogram describing the prior
flagwhether or not to use linear interpolation
Returns
An error code.

Definition at line 719 of file BCModel.cxx.

int BCModel::SetPriorConstant ( int  index)

Set constant prior for this parameter

Parameters
indexthe index of the parameter
Returns
An error code

Definition at line 732 of file BCModel.cxx.

int BCModel::SetPriorConstant ( const char *  name)
inline

Set constant prior for this parameter

Parameters
namethe name of the parameter
Returns
An error code

Definition at line 316 of file BCModel.h.

int BCModel::SetPriorConstantAll ( )

Enable caching the constant value of the prior, so LogAPrioriProbability is called only once. Note that the prior for ALL parameters is assumed to be constant. The value is computed from the parameter ranges, so make sure these are defined before this method is called.

Returns
An error code

Definition at line 753 of file BCModel.cxx.

int BCModel::SetPriorDelta ( int  index,
double  value 
)

Set delta-function prior for a parameter. Note: this sets the parameter range to the specified value. The old parameter range is lost.

Parameters
indexThe parameter index
valueThe position of the delta function.
Returns
An error code.

Definition at line 592 of file BCModel.cxx.

int BCModel::SetPriorDelta ( const char *  name,
double  value 
)

Set delta-function prior for a parameter. Note: this sets the parameter range to the specified value. The old parameter range is lost.

Parameters
nameThe parameter name
valueThe position of the delta function.
Returns
An error code.

Definition at line 602 of file BCModel.cxx.

int BCModel::SetPriorGauss ( int  index,
double  mean,
double  sigma 
)

Set Gaussian prior for a parameter.

Parameters
indexThe parameter index
meanThe mean of the Gaussian
sigmaThe sigma of the Gaussian
Returns
An error code.

Definition at line 610 of file BCModel.cxx.

int BCModel::SetPriorGauss ( const char *  name,
double  mean,
double  sigma 
)

Set Gaussian prior for a parameter.

Parameters
nameThe parameter name
meanThe mean of the Gaussian
sigmaThe sigma of the Gaussian
Returns
An error code.

Definition at line 631 of file BCModel.cxx.

int BCModel::SetPriorGauss ( int  index,
double  mean,
double  sigmadown,
double  sigmaup 
)

Set Gaussian prior for a parameter with two different widths.

Parameters
indexThe parameter index
meanThe mean of the Gaussian
sigmadownThe sigma (down) of the Gaussian
sigmaupThe sigma (up)of the Gaussian
Returns
An error code.

Definition at line 644 of file BCModel.cxx.

int BCModel::SetPriorGauss ( const char *  name,
double  mean,
double  sigmadown,
double  sigmaup 
)

Set Gaussian prior for a parameter with two different widths.

Parameters
nameThe parameter name
meanThe mean of the Gaussian
sigmadownThe sigma (down) of the Gaussian
sigmaupThe sigma (up)of the Gaussian
Returns
An error code.

Definition at line 669 of file BCModel.cxx.

void BCModel::SetSingleDataPoint ( BCDataPoint datapoint)

Sets a single data point as data set.

Parameters
datapointA data point

Definition at line 172 of file BCModel.cxx.

Member Data Documentation

BCDataPoint* BCModel::fDataPointLowerBoundaries
protected

data point containing the lower boundaries of possible data values

Definition at line 526 of file BCModel.h.

BCDataPoint* BCModel::fDataPointUpperBoundaries
protected

data point containing the upper boundaries of possible data values

Definition at line 530 of file BCModel.h.

BCDataSet* BCModel::fDataSet
protected

A data set

Definition at line 522 of file BCModel.h.

int BCModel::fGoFNChains
protected

Number of chains in the MCMC of the p-value evaluation using MCMC

Definition at line 558 of file BCModel.h.

int BCModel::fGoFNIterationsMax
protected

Maximum number of iterations in the MCMC pre-run of the p-value evaluation using MCMC

Definition at line 548 of file BCModel.h.

int BCModel::fGoFNIterationsRun
protected

Number of iterations in the MCMC normal run of the p-value evaluation using MCMC

Definition at line 553 of file BCModel.h.

bool BCModel::flag_discrete
protected

true for a discrete probability, false for continuous pdf

Definition at line 543 of file BCModel.h.

double BCModel::fModelAPosteriori
protected

The model a posteriori probability.

Definition at line 518 of file BCModel.h.

double BCModel::fModelAPriori
protected

The model prior probability.

Definition at line 514 of file BCModel.h.

std::string BCModel::fName
protected

Name of the model.

Definition at line 510 of file BCModel.h.

bool BCModel::fPriorConstantAll
protected

Flag to indicate that all parameters have constant prior.

Definition at line 566 of file BCModel.h.

std::vector<TNamed*> BCModel::fPriorContainer
protected

A vector of prior functions/histograms/graphs.

Definition at line 562 of file BCModel.h.

std::vector<bool> BCModel::fPriorContainerConstant
protected

List the parameters whose prior is constant

Definition at line 570 of file BCModel.h.

std::vector<bool> BCModel::fPriorContainerInterpolate
protected

List the parameters for which the histogram prior should be interpolated

Definition at line 574 of file BCModel.h.

double BCModel::fPValue
protected

The p-value

Definition at line 536 of file BCModel.h.


The documentation for this class was generated from the following files: