34using std::numeric_limits;
57 std::vector<double> &sampleWeights,
const char *varName)
88 const char * _columnName,
95 if( varName ) fVarName = varName;
99 TString columnName( _columnName );
101 if( !columnName.Length() ) {
102 columnName.Form(
"%s_TS0", name );
103 if( !dataSet.get()->find(columnName) ) {
104 columnName = dataSet.get()->first()->GetName();
110 fVarName = (*dataSet.get())[columnName].GetTitle();
115 for(
Int_t i=0; i < dataSet.numEntries(); i++) {
116 fSamplingDist.push_back(dataSet.get(i)->getRealValue(columnName));
117 fSampleWeights.push_back(dataSet.weight());
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;
int Int_t
Signed integer 4 bytes (int).
RooAbsArg * first() const
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'.
static constexpr double infinity()
Return internal infinity representation.
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
SamplingDistribution(const char *name, const char *title, std::vector< double > &samplingDist, const char *varName=nullptr)
Constructor for SamplingDistribution.
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
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.
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)