11 #ifndef ROOT_Math_GoFTest
12 #define ROOT_Math_GoFTest
49 enum EUserDistribution {
62 GoFTest(UInt_t sample1Size,
const Double_t* sample1, UInt_t sample2Size,
const Double_t* sample2);
65 GoFTest(UInt_t sampleSize,
const Double_t* sample, EDistribution dist = kUndefined);
69 GoFTest(UInt_t sampleSize,
const Double_t* sample, Dist& dist, EUserDistribution userDist = kPDF,
70 Double_t xmin = 1, Double_t xmax = 0)
72 Instantiate(sample, sampleSize);
73 SetUserDistribution<Dist>(dist, userDist, xmin, xmax);
77 GoFTest(UInt_t sampleSize,
const Double_t* sample,
const IGenFunction& dist, EUserDistribution userDist = kPDF,
78 Double_t xmin = 1, Double_t xmax = 0)
80 Instantiate(sample, sampleSize);
81 SetUserDistribution(dist, userDist, xmin, xmax);
86 void SetUserDistribution(Dist& dist, EUserDistribution userDist = kPDF, Double_t xmin = 1, Double_t xmax = 0) {
87 WrappedFunction<Dist&> wdist(dist);
88 SetDistributionFunction(wdist, userDist, xmin, xmax);
92 void SetUserDistribution(
const IGenFunction& dist, GoFTest::EUserDistribution userDist = kPDF, Double_t xmin = 1, Double_t xmax = 0) {
93 SetDistributionFunction(dist, userDist, xmin, xmax);
98 void SetUserPDF(Dist& pdf, Double_t xmin = 1, Double_t xmax = 0) {
99 SetUserDistribution<Dist>(pdf, kPDF, xmin, xmax);
103 void SetUserPDF(
const IGenFunction& pdf, Double_t xmin = 1, Double_t xmax = 0) {
104 SetUserDistribution(pdf, kPDF, xmin, xmax);
111 void SetUserCDF(Dist& cdf, Double_t xmin = 1, Double_t xmax = 0) {
112 SetUserDistribution<Dist>(cdf, kCDF, xmin, xmax);
116 void SetUserCDF(
const IGenFunction& cdf, Double_t xmin = 1, Double_t xmax = 0) {
117 SetUserDistribution(cdf, kCDF, xmin, xmax);
122 void SetDistribution(EDistribution dist);
132 void AndersonDarling2SamplesTest(Double_t& pvalue, Double_t& testStat)
const;
133 Double_t AndersonDarling2SamplesTest(
const Char_t* option =
"p")
const;
142 void AndersonDarlingTest(Double_t& pvalue, Double_t& testStat)
const;
143 Double_t AndersonDarlingTest(
const Char_t* option =
"p")
const;
150 void KolmogorovSmirnov2SamplesTest(Double_t& pvalue, Double_t& testStat)
const;
151 Double_t KolmogorovSmirnov2SamplesTest(
const Char_t* option =
"p")
const;
158 void KolmogorovSmirnovTest(Double_t& pvalue, Double_t& testStat)
const;
159 Double_t KolmogorovSmirnovTest(
const Char_t* option =
"p")
const;
162 void operator()(ETestType test, Double_t& pvalue, Double_t& testStat)
const;
166 Double_t operator()(ETestType test = kAD,
const Char_t* option =
"p")
const;
170 static Double_t PValueADKSamples(UInt_t nsamples, Double_t A2 );
173 static void AndersonDarling2SamplesTest(
const ROOT::Fit::BinData & data1,
const ROOT::Fit::BinData & data2, Double_t& pvalue, Double_t& testStat);
178 GoFTest(GoFTest& gof);
179 GoFTest operator=(GoFTest& gof);
181 std::unique_ptr<IGenFunction> fCDF;
189 std::vector<Double_t> fCombinedSamples;
191 std::vector<std::vector<Double_t> > fSamples;
193 Bool_t fTestSampleFromH0;
196 void SetDistributionFunction(
const IGenFunction& cdf, Bool_t isPDF, Double_t xmin, Double_t xmax);
198 void Instantiate(
const Double_t* sample, UInt_t sampleSize);
201 Double_t LogNormalCDF(Double_t x)
const;
202 Double_t GaussianCDF(Double_t x)
const;
203 Double_t ExponentialCDF(Double_t x)
const;
205 static Double_t GetSigmaN(
const std::vector<UInt_t> & ns, UInt_t N);
207 static Double_t InterpolatePValues(
int nsamples,Double_t A2);
210 Double_t PValueAD1Sample(Double_t A2)
const;
214 void SetSamples(std::vector<const Double_t*> samples,
const std::vector<UInt_t> samplesSizes);
216 void SetParameters();