Kolmogorov–Smirnov test, retrieve output




I would like to use the KS test on 2000 datasets and each time I run it just retrieve the output values into an array. Being quite new to Julia, I wonder how (and if) this is possible. Currently, I am doing ApproximateTwoSampleKSTest(x11,y11) which prints out all results to the screen like this

Approximate two sample Kolmogorov-Smirnov test

Population details:
parameter of interest: Supremum of CDF differences
value under h_0: 0.0
point estimate: 0.1540000000000001

Test summary:
outcome with 95% confidence: reject h_0
two-sided p-value: 1.0030026093285193e-10 (extremely significant)

number of observations: [1000,1000]
KS-statistic: 3.443544685349679




You can save the whole objects into an array easily, e.g. by results[11] = ApproximateTwoSampleKSTest(x11, y11), or if you are only after the p value you can results[11] = pvalue(ApproximateTwoSampleKSTest(x11, y11)). Interestingly, there does not seem to be a function to get the test statistic. You can get it by

function teststatistic(x)
    n = x.n_x*x.n_y/(x.n_x+x.n_y)

x = ApproximateTwoSampleKSTest(x11, y11)

I have taken this code from the package source. The x.n_x variables above refer to the field names of the object, you can see them by e.g. fieldnames(x).



Ja, I used the
results[11] = ApproximateTwoSampleKSTest(x11, y11)
option, and even figured out the pvalue function in the meantime, but I was really interested in storing the test statistics for all my 2000 tests. So great, thanks a lot.