- The class implements the Kolmogorov-Smmirnov and
Anderson-Darling tests for two samples (data vs data ) and
one sample (data vs distribution)
- For the data vs distribution test, the user can compare using a
predefined distributions (Gaussian, LogNormal or Exponential) or
by passing a user defined PDF or CDF.
- Example 1: perform a 2 sample GoF test from two arrays,
sample1[n1] and sample2[n2] containing the data
ROOT::Math::GoFTest goftest(n1, sample1, n2, sample2);
double pValueAD = goftest.AndersonDarling2SamplesTest();
double pValueKS = goftest.KolmogorovSmirnov2SamplesTest();
The class can return optionally also the test statistics instead of
the p value.
- Example 2: perform a 1 sample test with a pre-defined
distribution starting from a data set sample[n]
ROOT::Math::GoFTest goftest(n, sample, ROOT::Math::GoFTest::kGaussian);
double pValueAD = goftest.AndersonDarlingTest();
double pValueKS = goftest.KolmogorovSmirnovTest();
- Example 3: perform a 1 sample test with a user-defined
distribution provided as cdf
ROOT::Math::Functor1D cdf_func(&ROOT::Math::landau_cdf);
ROOT::Math::GofTest goftest(n, sample, cdf_func, ROOT::Math::GoFTest::kCDF);
double pValueAD = goftest.AndersonDarlingTest();
- Example 4: perform a 1 sample test with a user-defined
distribution provided as pdf. Note that in this case to avoid
integration problems is sometimes reccomended to give some
reasanable xmin and xmax values. xmin (and xmax) should however be
smaller (larger) than the minimum (maximum) data value.
ROOT::Math::Functor1D pdf_func(&ROOT::Math::landau_pdf);
double xmin = 5*TMath::Min_Element(n,sample);
double xmax = 5*TMath::Max_Element(n,sample);
ROOT::Math::GofTest goftest(n, sample, pdf_func, ROOT::Math::GoFTest::kPDF,xmin,xmax);
double pValueAD = goftest.AndersonDarlingTest();