# Kolmogorov Test

Hi all–

I am writing a script in which I compare two arrays using the Kolmogorov-Smirnov (KS) test, and for some reason I keep getting a “Not defined in current scope” error. Here’s a toy version of my code:

{

Int_t y;
double x, x_sort;
double z;

for (Int_t i=0; i<5; i++) {
x[i] = 5 - i;
}

for (Int_t j=0; j<50, j++){
z[j] = j;
}

//I also used this script to learn how Sort() works
TMath::Sort(5, x, y, kFALSE);

//The KS test needs the arrays sorted in ascending order
for (Int_t i=0; i<5; i++) {
x_sort[i] = x[y[i]];
}

cout << "KS: " << KolmogorovTest(5, x_sort, 50, z) << endl;

}

The error message this gives is pretty standard:

“Error: Function KolmogorovTest(5,x_sort,50,z) is not defined in current scope”

What’s weird to me is that both Sort() and KolmogorovTest() are defined in TMath, but I’m apparently not calling KTest properly. I’m sure whatever’s going on here is a silly oversight, but I’d appreciate any help.

Thanks!

You are missing the namespace TMath and the last argument. Change

```cout << "KS: " << KolmogorovTest(5, x_sort, 50, z) << endl; ```to

```cout << "KS: " << TMath::KolmogorovTest(5, x_sort, 50, z,"") << endl; ```

Rene

Actually I had the TMath:: in there already (had to type the script out anew because I couldn’t copy it over from emacs), but I saw that you added a blank string for the final argument and that did the trick! Thanks a ton.