BAT
0.9.4
The Bayesian analysis toolkit
|
A class for fitting histograms with functions. More...
#include <BCHistogramFitter.h>
Public Member Functions | |
Constructors and destructors | |
BCHistogramFitter () | |
BCHistogramFitter (const char *name) | |
BCHistogramFitter (TH1D *hist, TF1 *func) | |
BCHistogramFitter (const char *name, TH1D *hist, TF1 *func) | |
~BCHistogramFitter () | |
Member functions (get) | |
TH1D * | GetHistogram () |
TH1D * | GetHistogramExpected () |
TF1 * | GetFitFunction () |
TGraph * | GetErrorBand () |
TGraph * | GetGraphFitFunction () |
Member functions (set) | |
int | SetHistogram (TH1D *hist) |
int | SetHistogramExpected (const std::vector< double > ¶meters) |
int | SetFitFunction (TF1 *func) |
void | SetFlagIntegration (bool flag) |
Member functions (miscellaneous methods) | |
virtual double | LogLikelihood (const std::vector< double > ¶meters) |
double | FitFunction (const std::vector< double > &x, const std::vector< double > ¶meters) |
int | Fit () |
int | Fit (TH1D *hist, TF1 *func) |
void | DrawFit (const char *options="HIST", bool flaglegend=false) |
int | CalculatePValueFast (const std::vector< double > &par, unsigned nIterations=100000) |
int | CalculatePValueLikelihood (const std::vector< double > &par) |
int | CalculatePValueLeastSquares (const std::vector< double > &par, bool weightExpect=true) |
int | CalculatePValueKolmogorov (const std::vector< double > &par) |
double | CDF (const std::vector< double > ¶meters, int index, bool lower=false) |
![]() | |
BCFitter () | |
BCFitter (const char *name) | |
~BCFitter () | |
TGraph * | GetErrorBand () |
TH2D * | GetErrorBandXY () const |
TH2D * | GetErrorBandXY_yellow (double level=.68, int nsmooth=0) const |
std::vector< double > | GetErrorBand (double level) const |
TGraph * | GetErrorBandGraph (double level1, double level2) const |
TGraph * | GetFitFunctionGraph (const std::vector< double > ¶meters) |
TGraph * | GetFitFunctionGraph () |
TGraph * | GetFitFunctionGraph (const std::vector< double > ¶meters, double xmin, double xmax, int n=1000) |
void | FixDataAxis (unsigned int index, bool fixed) |
bool | GetFixedDataAxis (unsigned int index) const |
void | SetFillErrorBand (bool flag=true) |
void | SetErrorBandHisto (TH2D *h) |
void | UnsetFillErrorBand () |
void | SetFitFunctionIndexX (int index) |
void | SetFitFunctionIndexY (int index) |
void | SetFitFunctionIndices (int indexx, int indexy) |
void | SetErrorBandContinuous (bool flag) |
int | ReadErrorBandFromFile (const char *file) |
void | MCMCIterationInterface () |
void | MarginalizePreprocess () |
void | MarginalizePostprocess () |
void | FillErrorBand () |
![]() | |
BCModel (const char *name="model") | |
BCModel (const BCModel &bcmodel) | |
virtual | ~BCModel () |
BCModel & | operator= (const BCModel &bcmodel) |
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 |
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 () |
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) |
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) |
Additional Inherited Members | |
![]() | |
TH2D * | fErrorBandXY |
![]() | |
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 |
A class for fitting histograms with functions.
Definition at line 35 of file BCHistogramFitter.h.
BCHistogramFitter::BCHistogramFitter | ( | ) |
The default constructor.
Definition at line 30 of file BCHistogramFitter.cxx.
BCHistogramFitter::BCHistogramFitter | ( | const char * | name | ) |
BCHistogramFitter::BCHistogramFitter | ( | TH1D * | hist, |
TF1 * | func | ||
) |
Constructor.
hist | histogram to fit |
func | fit function |
Definition at line 66 of file BCHistogramFitter.cxx.
BCHistogramFitter::BCHistogramFitter | ( | const char * | name, |
TH1D * | hist, | ||
TF1 * | func | ||
) |
Constructor
name | name of the model |
hist | histogram to fit |
func | fit function |
Definition at line 86 of file BCHistogramFitter.cxx.
BCHistogramFitter::~BCHistogramFitter | ( | ) |
The default destructor.
Definition at line 259 of file BCHistogramFitter.cxx.
int BCHistogramFitter::CalculatePValueFast | ( | const std::vector< double > & | par, |
unsigned | nIterations = 100000 |
||
) |
Calculate the p-value using fast-MCMC and the likelihood as test statistic. The method is explained in the appendix of http://arxiv.org/abs/1011.1674
par | The parameter values for which expectations are computed |
nIterations | number of pseudo experiments generated by the Markov chain |
Definition at line 442 of file BCHistogramFitter.cxx.
int BCHistogramFitter::CalculatePValueKolmogorov | ( | const std::vector< double > & | par | ) |
Calculate the p-value using Kolmogorov-Smirnov test. Note that the reference distribution is known only asymptotically. Some explanation is given in http://root.cern.ch/root/htmldoc/TMath.html
par | The set of parameter values used in the model, usually the best fit parameters |
pvalue | The pvalue |
Definition at line 554 of file BCHistogramFitter.cxx.
int BCHistogramFitter::CalculatePValueLeastSquares | ( | const std::vector< double > & | par, |
bool | weightExpect = true |
||
) |
Calculate the p-value using approximate chi^2 distribution of squared difference for conventional weights. Approximation is valid for bin contents >5 and not as as good for little data as CalculatePValueLikelihood, see eq. (32.13), PDG: Statistics, Monte Carlo, Group Theory. Physics Letters B 667, 316-339(2008).
par | The set of parameter values used in the model, usually the best fit parameters |
pvalue | The pvalue |
weight | use the variance from the expected #counts (true) or the measured counts (false) |
Definition at line 517 of file BCHistogramFitter.cxx.
int BCHistogramFitter::CalculatePValueLikelihood | ( | const std::vector< double > & | par | ) |
Calculate the p-value using approximate chi^2 distribution of scaled likelihood. Approximation is valid for bin contents >5, see eq. (32.12), PDG: Statistics, Monte Carlo, Group Theory. Physics Letters B 667, 316-339(2008).
par | The set of parameter values used in the model, usually the best fit parameters |
pvalue | The pvalue |
Definition at line 481 of file BCHistogramFitter.cxx.
|
virtual |
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 from BCModel.
Definition at line 576 of file BCHistogramFitter.cxx.
|
virtual |
Draw the fit in the current pad.
Implements BCFitter.
Definition at line 389 of file BCHistogramFitter.cxx.
|
virtual |
Performs the fit.
Implements BCFitter.
Definition at line 351 of file BCHistogramFitter.cxx.
int BCHistogramFitter::Fit | ( | TH1D * | hist, |
TF1 * | func | ||
) |
Performs the fit.
hist | The histogram (TH1D). |
func | The fit function. |
Definition at line 328 of file BCHistogramFitter.cxx.
|
virtual |
Plots the histogram
options | Options for plotting. |
filename | Name of the file which the histogram is printed into. The following options are available: F : plots the fit function on top of the data E0 : plots the fit function and the 68% prob. uncertainty band of the fit function on top of the data E1 : plots the expectation from the fit function and the uncertainty bin-by-bin as error bars. Returns the y-value of the 1-dimensional fit function at an x and for a set of parameters. |
x | A vector with the x-value. |
parameters | A set of parameters. |
Reimplemented from BCFitter.
Definition at line 318 of file BCHistogramFitter.cxx.
|
inline |
Definition at line 91 of file BCHistogramFitter.h.
|
inline |
Definition at line 86 of file BCHistogramFitter.h.
|
inline |
Definition at line 96 of file BCHistogramFitter.h.
|
inline |
Definition at line 75 of file BCHistogramFitter.h.
|
inline |
Definition at line 80 of file BCHistogramFitter.h.
|
virtual |
The log of the prior probability. Overloaded from BCModel.
parameters | A vector of doubles containing the parameter values. The log of the conditional probability. Overloaded from BCModel. |
parameters | A vector of doubles containing the parameter values. |
Implements BCModel.
Definition at line 267 of file BCHistogramFitter.cxx.
int BCHistogramFitter::SetFitFunction | ( | TF1 * | func | ) |
func | The fit function |
Definition at line 220 of file BCHistogramFitter.cxx.
|
inline |
Sets the flag for integration.
true: use ROOT's TH1D::Integrate()
false: use linear interpolation
Definition at line 126 of file BCHistogramFitter.h.
int BCHistogramFitter::SetHistogram | ( | TH1D * | hist | ) |
hist | The histogram containing the data |
Definition at line 106 of file BCHistogramFitter.cxx.
int BCHistogramFitter::SetHistogramExpected | ( | const std::vector< double > & | parameters | ) |
hist | The histogram with the expected counts (typically non-integer values!) |
Definition at line 162 of file BCHistogramFitter.cxx.