KSTWO
Name
KSTWO
Purpose
Return the two-sided Kolmogorov-Smirnov statistic
Explanation
Returns the Kolmogorov-Smirnov statistic and associated probability
that two arrays of data values are drawn from the same distribution
Algorithm taken from procedure of the same name in "Numerical
Recipes" by Press et al., 2nd edition (1992), Chapter 14
Calling Sequence
kstwo, data1, data2, D, prob
INPUT PARAMATERS:
data1 - vector of data values, at least 4 data values must be included
for the K-S statistic to be meaningful
data2 - second set of data values, does not need to have the same
number of elements as data1
Output Parameters
D - floating scalar giving the Kolmogorov-Smirnov statistic. It
specifies the maximum deviation between the cumulative
distribution of the data and the supplied function
prob - floating scalar between 0 and 1 giving the significance level of
the K-S statistic. Small values of PROB show that the
cumulative distribution function of DATA1 is significantly
different from DATA2
Example
Test whether two vectors created by the RANDOMN function likely came
from the same distribution
IDL> data1 = randomn(seed,40) ;Create data vectors to be
IDL> data2 = randomn(seed,70) ;compared
IDL> kstwo, data1, data2, D, prob & print,D,prob
Procedure Calls
procedure PROB_KS - computes significance of K-S distribution
Revision History
Written W. Landsman August, 1992
FP computation of N_eff H. Ebeling/W. Landsman March 1996
Fix for arrays containing equal values J. Ballet/W. Landsman Oct. 2001
Fix index when maximum difference is at array end Renbin Yan Dec 2008
Handle large number when computing N_err D. Schnitzeler/WL Sep 2010