29 return 1 - pow(1.0 + xi*y/sigma_bar, -1.0/xi);
32 double d = 1.0 + xi*y/fabs(sigma_bar);
34 return (1./fabs(sigma_bar))*pow(1.0 + xi*y/fabs(sigma_bar), -1.0/xi - 1.0);
37 double d = 1.0 + xi*y/fabs(sigma_bar);
38 if(d < 0)
return -99999;
39 return -log(fabs(sigma_bar)) + log(1.0 + xi*y/fabs(sigma_bar)) *(-1.0/xi - 1.0);
44 return 0.5*(1.0 - mean*mean/(rms*rms));
48 return 0.5*mean*(1.0 + mean*mean/(rms*rms));
53 return sigma_bar/xi * ( pow( 1.0 - CL , -xi) - 1.0 );
58 cout <<
" MINT::generalisedPareto_limit: Limit only for negative xi." 59 <<
" This xi = " << xi << endl;
67 double paretoMax=-9999;
68 double actualMax=-9999;
78 ,
double xiInit,
double sigInit)
80 , _threshold(threshold)
81 , _xi(
"xi", 0, xiInit, fabs(xiInit)/2.0 + 0.1, 0, 0, &_mps)
82 , _sigma(
"sigma", 0, fabs(sigInit), fabs(sigInit)/2.0 + 0.1, 0, 0, &_mps)
88 for(
unsigned int i=0; i < _data.size(); i++){
89 double x = _data[i] - _threshold;
108 std::vector<double> input;
109 for(
unsigned int i=0; i < input_a.size(); i++){
110 if(i > 0 && i%200 == 0){
111 input.push_back(max);
114 if(input_a[i] > max) max=input_a[i];
117 sort(input.begin(), input.end());
119 unsigned int n=-9999;
123 n = (
unsigned int) numEvents;
130 if(n > input.size()) n = input.size()-1;
132 cout <<
"MINT::generalisedPareto_estimateMaximum: " 133 << input.size() <<
" too few events." 137 double sum=0, sumsq=0;
138 unsigned int counter=0;
139 double lastVal=-9999;
140 std::vector<double>::reverse_iterator it = input.rbegin();
143 it != input.rend() && counter < n;
145 if(dbThis) cout << *it << endl;
148 sumsq += (lastVal) * (lastVal);
150 double threshold = 0.5*(lastVal + *it);
152 double mean = sum/((double)n);
153 double meansq = sumsq/((double)n);
154 double var = meansq - mean*mean;
155 double rms = sqrt(var);
160 if(sg < -1.5*xi*(maxVal-threshold)) sg = fabs(1.5*xi*(maxVal-threshold));
162 cout <<
"xi, sg before fit: xi = " << xi <<
", sg = " << sg << endl;
168 cout <<
"xi, sg after fit: xi = " << xi <<
", sg = " << sg << endl;
170 double limity = -9999;
177 double limit = limity + threshold;
179 if(verbose || dbThis){
180 cout <<
"MINT::generalisedPareto_estimateMaximum with CL = " << CL << endl;
181 cout <<
"\n maxVal " << maxVal
182 <<
"\n mean " << mean
184 <<
"\n threshold " << threshold
187 <<
"\n limity " << limity
188 <<
"\n limit " << limit
192 cout <<
"MINT::generalisedPareto_estimateMaximum with CL = " << CL
193 <<
": Something clearly went wrong" 194 <<
"\n Estimated upper limit smaller than actual upper limit:" 195 <<
" actual: " << maxVal <<
", estimated " << limit << endl;
double generalisedPareto_yFromCL(double CL, double xi, double sigma_bar)
double generalisedPareto_sigmaFromMeanRMS(double mean, double rms)
double generalisedPareto_xiFromMeanRMS(double mean, double rms)
double generalisedPareto_estimateMaximum(const std::vector< double > &input, double CL=0.001)
double generalisedPareto_pdf(double y, double xi, double sigma_bar)
static MinuitParameterSet _mps
minimisePareto(std::vector< double > &data, double threshold, double xiInit, double sigInit)
void setPset(MinuitParameterSet *mps)
double generalisedPareto_cumulative(double y, double xi, double sigma_bar)
double generalisedPareto_limit(double xi, double sigma_bar)
double generalisedPareto_logPdf(double y, double xi, double sigma_bar)