// @(#)root/roostats:$Id$
// Author: Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke
/*************************************************************************
* Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
//_________________________________________________
/*
BEGIN_HTML
BayesianCalculator is a concrete implementation of IntervalCalculator, providing the computation
of a credible interval using a Bayesian method.
The class works only for one single parameter of interest and it integrates the likelihood function with the given prior
probability density function to compute the posterior probability. The result of the class is a one dimensional interval
(class SimpleInterval ), which is obtained from inverting the cumulative posterior distribution.
The interface allows one to construct the class by passing the data set, probability density function for the model, the prior
functions and then the parameter of interest to scan. The nuisance parameters can also be passed to be marginalized when
computing the posterior. Alternatively, the class can be constructed by passing the data and the ModelConfig containing
all the needed information (model pdf, prior pdf, parameter of interest, nuisance parameters, etc..)
After configuring the calculator, one only needs to ask GetInterval(), which
will return an SimpleInterval object. By default the extrem of the integral are obtained by inverting directly the
cumulative posterior distribution. By using the method SetScanOfPosterior(nbins) the interval is then obtained by
scanning the posterior function in the given number of points. The firts method is in general faster but it requires an
integration one extra dimension ( in the poi in addition to the nuisance parameters), therefore in some case it can be
less robust.
The class can also return the posterior function (method GetPosteriorFunction) or if needed the normalized
posterior function (the posterior pdf) (method GetPosteriorPdf). A posterior plot is also obtained using
the GetPosteriorPlot method.
The class allows to use different integration methods for integrating in the nuisances and in the poi. All the numerical
integration methods of ROOT can be used via the method SetIntegrationType (see more in the documentation of
this method).
END_HTML
*/
//_________________________________________________
// include other header files
#include "RooAbsFunc.h"
#include "RooAbsReal.h"
#include "RooRealVar.h"
#include "RooArgSet.h"
#include "RooBrentRootFinder.h"
#include "RooFormulaVar.h"
#include "RooGenericPdf.h"
#include "RooPlot.h"
#include "RooProdPdf.h"
#include "RooDataSet.h"
// include header file of this class
#include "RooStats/BayesianCalculator.h"
#include "RooStats/ModelConfig.h"
#include "RooStats/RooStatsUtils.h"
#include "Math/IFunction.h"
#include "Math/IntegratorMultiDim.h"
#include "Math/Integrator.h"
#include "Math/RootFinder.h"
#include "Math/BrentMinimizer1D.h"
#include "RooFunctor.h"
#include "RooFunctor1DBinding.h"
#include "RooTFnBinding.h"
#include "RooMsgService.h"
#include "TAxis.h"
#include "TF1.h"
#include "TH1.h"
#include "TMath.h"
#include "TCanvas.h"
#include