34using std::numeric_limits;
44 :
TNamed(
name, title), fSamplingDist(samplingDist), fVarName(varName)
57 std::vector<double> &sampleWeights,
const char *varName)
58 :
TNamed(
name, title), fSamplingDist(samplingDist), fSampleWeights(sampleWeights), fVarName(varName)
88 const char * _columnName,
99 TString columnName( _columnName );
101 if( !columnName.
Length() ) {
103 if( !dataSet.
get()->
find(columnName) ) {
156 for(
unsigned int i=0; i<newSamplingDist.size(); ++i){
191 std::vector<unsigned int>
index(
n);
195 fSumW = std::vector<double>(
n );
196 fSumW2 = std::vector<double>(
n );
198 std::vector<double> sortedDist(
n);
199 std::vector<double> sortedWeights(
n);
201 for(
unsigned int i=0; i <
n; i++) {
202 unsigned int j =
index[i];
231 error = numeric_limits<double>::infinity();
235 if (
int(
fSumW.size()) !=
n)
261 assert(indexLow <
n && indexHigh <
n);
266 if (indexHigh >= 0) {
278 double norm =
fSumW.back();
279 double norm2 =
fSumW2.back();
285 error = std::sqrt( sum2 * (1. - 2. *
sum) + norm2 *
sum *
sum ) / norm;
288 error = std::sqrt(sum2);
315 double sigmaVariation,
316 double& inverseWithVariation)
322 Warning(
"InverseCDF",
"Estimation of Quantiles (InverseCDF) for weighted events is not yet supported");
347 else if(pvalue < 0.5){
348 int delta = (
int)(sigmaVariation*sqrt(1.0*nominal));
349 int variation = nominal+delta;
353 }
else if (variation <= 0) {
361 else if(pvalue >= 0.5){
363 int variation = nominal+delta;
368 }
else if (variation <= 0) {
383 coutE(Eval) <<
"problem in SamplingDistribution::InverseCDF" << std::endl;
400 Warning(
"InverseCDFInterpolate",
"Estimation of Quantiles (InverseCDF) for weighted events is not yet supported.");
418 return (upperX-lowerX)/(upperY-lowerY)*(pvalue-lowerY)+lowerX;
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
double getRealValue(const char *name, double defVal=0.0, bool verbose=false) const
Get value of a RooAbsReal stored in set with given name.
RooAbsArg * first() const
RooAbsArg * find(const char *name) const
Find object with given name in list.
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
Container class to hold unbinned data.
const RooArgSet * get(Int_t index) const override
Return RooArgSet with coordinates of event 'index'.
double weight() const override
Return event weight of current event.
static constexpr double infinity()
Return internal infinity representation.
This class simply holds a sampling distribution of some test statistic.
double Integral(double low, double high, bool normalize=true, bool lowClosed=true, bool highClosed=false) const
numerical integral in these limits
double CDF(double x) const
calculate CDF as a special case of Integral(...) with lower limit equal to -inf
~SamplingDistribution() override
Destructor of SamplingDistribution.
std::vector< double > fSumW2
! Cached vector with sum of the weight used to compute integral error
double InverseCDFInterpolate(double pvalue)
get the inverse of the Cumulative distribution function
std::vector< double > fSumW
! Cached vector with sum of the weight used to compute integral
SamplingDistribution()
Default constructor for SamplingDistribution.
std::vector< double > fSamplingDist
vector of points for the sampling distribution
double IntegralAndError(double &error, double low, double high, bool normalize=true, bool lowClosed=true, bool highClosed=false) const
numerical integral in these limits including error estimation
double InverseCDF(double pvalue)
get the inverse of the Cumulative distribution function
void Add(const SamplingDistribution *other)
merge two sampling distributions
const TString GetVarName() const
void SortValues() const
internal function to sort values
std::vector< double > fSampleWeights
vector of weights for the samples
The TNamed class is the base class for all named ROOT classes.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
virtual void SetName(const char *name)
Set the name of the TNamed.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Namespace for the RooStats classes.
void SortItr(Iterator first, Iterator last, IndexIterator index, Bool_t down=kTRUE)
Sort the n1 elements of the Short_t array defined by its iterators.
Bool_t AreEqualRel(Double_t af, Double_t bf, Double_t relPrec)
Comparing floating points.
static uint64_t sum(uint64_t i)