#include #include "TMath.h" void KStest() { const int n = 1000; //number of entries in arrays const int N= 2000; //number of kolmogorov probabilities (how many times i perform the test) Double_t a,b,Ktest1; Double_t arr1[n], arr2[n]; //histogram of kolmogorow probabilities TH1F *unbinnedyes = new TH1F ("unbinnedyes","KS unbinned same", 100,0,1); unbinnedyes->SetFillColor(kGreen); for (int j=0; jUniform(); b=gRandom->Uniform(); arr1[i]=a; arr2[i]=b; } //sort the array std::sort(arr1,arr1+n); std::sort(arr2,arr2+n); //do kolmogorov test for unbinned data, fill the probability values into histogram Ktest1 = TMath::KolmogorovTest (n, arr1,n,arr2,""); unbinnedyes->Fill(Ktest1); } //plot the distribution of KS probability - supposed to be flat! unbinnedyes->Draw(); }