34using std::numeric_limits;
45 :
TNamed(
name, title), fSamplingDist(samplingDist), fVarName(varName)
58 std::vector<double> &sampleWeights,
const char *varName)
59 :
TNamed(
name, title), fSamplingDist(samplingDist), fSampleWeights(sampleWeights), fVarName(varName)
89 const char * _columnName,
95 if( dataSet.numEntries() == 0 || !dataSet.get()->first() ) {
100 TString columnName( _columnName );
102 if( !columnName.
Length() ) {
104 if( !dataSet.get()->find(columnName) ) {
105 columnName = dataSet.get()->first()->GetName();
116 for(
Int_t i=0; i < dataSet.numEntries(); i++) {
117 fSamplingDist.push_back(dataSet.get(i)->getRealValue(columnName));
157 for(
unsigned int i=0; i<newSamplingDist.size(); ++i){
192 std::vector<unsigned int>
index(
n);
196 fSumW = std::vector<double>(
n );
197 fSumW2 = std::vector<double>(
n );
199 std::vector<double> sortedDist(
n);
200 std::vector<double> sortedWeights(
n);
202 for(
unsigned int i=0; i <
n; i++) {
203 unsigned int j =
index[i];
232 error = numeric_limits<double>::infinity();
236 if (
int(
fSumW.size()) !=
n)
262 assert(indexLow <
n && indexHigh <
n);
267 if (indexHigh >= 0) {
279 double norm =
fSumW.back();
280 double norm2 =
fSumW2.back();
286 error = std::sqrt( sum2 * (1. - 2. *
sum) + norm2 *
sum *
sum ) / norm;
289 error = std::sqrt(sum2);
316 double sigmaVariation,
317 double& inverseWithVariation)
323 Warning(
"InverseCDF",
"Estimation of Quantiles (InverseCDF) for weighted events is not yet supported");
348 else if(pvalue < 0.5){
349 int delta = (
int)(sigmaVariation*sqrt(1.0*nominal));
350 int variation = nominal+delta;
354 }
else if (variation <= 0) {
362 else if(pvalue >= 0.5){
364 int variation = nominal+delta;
369 }
else if (variation <= 0) {
384 std::cout <<
"problem in SamplingDistribution::InverseCDF" << std::endl;
401 Warning(
"InverseCDFInterpolate",
"Estimation of Quantiles (InverseCDF) for weighted events is not yet supported.");
419 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
Container class to hold unbinned data.
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)