BAT
0.9.4
The Bayesian analysis toolkit
|
The base class for all user-defined models. More...
#include <BCModel.h>
Public Member Functions | |
Constructors and destructors | |
BCModel (const char *name="model") | |
BCModel (const BCModel &bcmodel) | |
virtual | ~BCModel () |
Assignment operators | |
BCModel & | operator= (const BCModel &bcmodel) |
Member functions (get) | |
const std::string & | GetName () const |
double | GetModelAPrioriProbability () const |
double | GetModelAPosterioriProbability () const |
BCDataSet * | GetDataSet () const |
BCDataPoint * | GetDataPointLowerBoundaries () const |
BCDataPoint * | GetDataPointUpperBoundaries () const |
double | GetDataPointLowerBoundary (unsigned int index) const |
double | GetDataPointUpperBoundary (unsigned int index) const |
bool | GetFlagBoundaries () const |
unsigned | GetNDataPoints () const |
BCDataPoint * | GetDataPoint (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 > ¶meters) |
virtual double | LogAPrioriProbability (const std::vector< double > ¶meters) |
virtual double | Likelihood (const std::vector< double > ¶ms) |
virtual double | LogLikelihood (const std::vector< double > ¶ms)=0 |
double | ProbabilityNN (const std::vector< double > ¶ms) |
double | LogProbabilityNN (const std::vector< double > ¶meters) |
double | Probability (const std::vector< double > ¶meter) |
double | LogProbability (const std::vector< double > ¶meter) |
virtual double | SamplingFunction (const std::vector< double > ¶meters) |
double | Eval (const std::vector< double > ¶meters) |
virtual double | LogEval (const std::vector< double > ¶meters) |
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) |
BCH1D * | CalculatePValue (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 |
BCDataSet * | fDataSet |
BCDataPoint * | fDataPointLowerBoundaries |
BCDataPoint * | fDataPointUpperBoundaries |
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 |
The base class for all user-defined models.
BCModel::BCModel | ( | const char * | name = "model" | ) |
BCModel::BCModel | ( | const BCModel & | bcmodel | ) |
The copy constructor.
Definition at line 56 of file BCModel.cxx.
|
virtual |
The default destructor.
Definition at line 104 of file BCModel.cxx.
|
virtual |
Adds a parameter to the model.
parameter | A model parameter |
Definition at line 225 of file BCModel.cxx.
double BCModel::APrioriProbability | ( | const std::vector< double > & | parameters | ) |
Returns the prior probability.
parameters | A set of parameter values |
Definition at line 267 of file BCModel.cxx.
|
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 | The parameter values at which point to compute the cdf |
index | The data point index starting at 0,1...N-1 |
lower | only 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.
void BCModel::Copy | ( | const BCModel & | bcmodel | ) |
|
virtual |
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
dataIndex | component of datapoint with the observed value |
sigmaIndex | component of datapoint with uncertainty |
Definition at line 368 of file BCModel.cxx.
BCDataPoint * BCModel::GetDataPoint | ( | unsigned int | index | ) | const |
index | The index of the data point. |
Definition at line 132 of file BCModel.cxx.
|
inline |
double BCModel::GetDataPointLowerBoundary | ( | unsigned int | index | ) | const |
index | The index of the variable. |
Definition at line 142 of file BCModel.cxx.
|
inline |
double BCModel::GetDataPointUpperBoundary | ( | unsigned int | index | ) | const |
index | The index of the variable. |
Definition at line 148 of file BCModel.cxx.
|
inline |
bool BCModel::GetFlagBoundaries | ( | ) | const |
Checks if the boundaries have been defined
Definition at line 154 of file BCModel.cxx.
|
inline |
|
inline |
|
inline |
unsigned BCModel::GetNDataPoints | ( | ) | const |
Definition at line 123 of file BCModel.cxx.
double BCModel::GetPvalueFromChi2 | ( | const std::vector< double > & | par, |
int | sigma_index | ||
) |
Calculate p-value from Chi2 distribution for Gaussian problems
par | Parameter set for the calculation of the likelihood |
sigma_index | Index 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.
par | Parameter set for the calculation of the likelihood |
index | Index 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
parameter1 | The parameter for the first derivative |
parameter2 | The parameter for the first derivative |
Definition at line 501 of file BCModel.cxx.
|
virtual |
Returns the likelihood
params | A set of parameter values |
Definition at line 324 of file BCModel.cxx.
|
virtual |
Returns natural logarithm of the prior probability. Method needs to be overloaded by the user.
parameters | A set of parameter values |
Reimplemented in BCGoFTest, BCMVCDataModel, BCSummaryPriorModel, and BCRooInterface.
Definition at line 273 of file BCModel.cxx.
|
virtual |
Overloaded function to evaluate integral.
Definition at line 336 of file BCModel.cxx.
|
pure virtual |
Calculates natural logarithm of the likelihood. Method needs to be overloaded by the user.
params | A set of parameter values |
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 | A set of parameter values |
Definition at line 255 of file BCModel.cxx.
|
inline |
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 | The 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 | A set of parameter values |
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
params | A set of parameter values |
Definition at line 243 of file BCModel.cxx.
|
virtual |
Sampling function used for importance sampling. Method needs to be overloaded by the user.
parameters | A set of parameter values |
Definition at line 342 of file BCModel.cxx.
|
inline |
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.
|
inline |
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.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
int BCModel::SetPrior | ( | int | index, |
TF1 * | f | ||
) |
Set prior for a parameter.
index | The parameter index |
f | A pointer to a function describing the prior |
Definition at line 558 of file BCModel.cxx.
int BCModel::SetPrior | ( | const char * | name, |
TF1 * | f | ||
) |
Set prior for a parameter.
name | The parameter name |
f | A pointer to a function describing the prior |
Definition at line 579 of file BCModel.cxx.
int BCModel::SetPrior | ( | int | index, |
TH1 * | h, | ||
bool | flag = false |
||
) |
Set prior for a parameter.
index | parameter index |
h | pointer to a histogram describing the prior |
flag | whether or not to use linear interpolation |
Definition at line 682 of file BCModel.cxx.
int BCModel::SetPrior | ( | const char * | name, |
TH1 * | h, | ||
bool | flag = false |
||
) |
Set prior for a parameter.
name | parameter name |
h | pointer to a histogram describing the prior |
flag | whether or not to use linear interpolation |
Definition at line 719 of file BCModel.cxx.
int BCModel::SetPriorConstant | ( | int | index | ) |
Set constant prior for this parameter
index | the index of the parameter |
Definition at line 732 of file BCModel.cxx.
|
inline |
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.
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.
index | The parameter index |
value | The position of the delta function. |
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.
name | The parameter name |
value | The position of the delta function. |
Definition at line 602 of file BCModel.cxx.
int BCModel::SetPriorGauss | ( | int | index, |
double | mean, | ||
double | sigma | ||
) |
Set Gaussian prior for a parameter.
index | The parameter index |
mean | The mean of the Gaussian |
sigma | The sigma of the Gaussian |
Definition at line 610 of file BCModel.cxx.
int BCModel::SetPriorGauss | ( | const char * | name, |
double | mean, | ||
double | sigma | ||
) |
Set Gaussian prior for a parameter.
name | The parameter name |
mean | The mean of the Gaussian |
sigma | The sigma of the Gaussian |
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.
index | The parameter index |
mean | The mean of the Gaussian |
sigmadown | The sigma (down) of the Gaussian |
sigmaup | The sigma (up)of the Gaussian |
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.
name | The parameter name |
mean | The mean of the Gaussian |
sigmadown | The sigma (down) of the Gaussian |
sigmaup | The sigma (up)of the Gaussian |
Definition at line 669 of file BCModel.cxx.
void BCModel::SetSingleDataPoint | ( | BCDataPoint * | datapoint | ) |
Sets a single data point as data set.
datapoint | A data point |
Definition at line 172 of file BCModel.cxx.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |