
KOLMOGOROV SMIRNOV TWO SAMPLEName:
where n_{i} is the number of points less than Y_{i}. This is a step function that increases by 1/N at the value of each data point. We can graph a plot of the empirical distribution function with a cumulative distribution function for a given distribution. The one sample KS test is based on the maximum distance between these two curves. That is,
where F is the theoretical cumulative distribution function. The two sample KS test is a variation of this. However, instead of comparing an empirical distribution function to a theoretical distribution function, we compare the two empirical distribution functions. That is,
where E_{1} and E_{2} are the empirical distribution functions for the two samples. Note that we compute E_{1} and E_{2} at each point in both samples (that is both E_{1} and E_{2} are computed at each point in each sample). More formally, the KolmogorovSmirnov two sample test statistic can be defined as follows.
The quantilequantile plot, bihistogram, and Tukey meandifference plot are graphical alternatives to the two sample KS test.
<SUBSET/EXCEPT/FOR/qualification> where <y1> is the first response variable; <y2> is the second response variable; and where the <SUBSET/EXCEPT/FOR qualification> is optional.
<SUBSET/EXCEPT/FOR/qualification> where <y1> ... <yk> is a list of 2 to 30 response variables; and where the <SUBSET/EXCEPT/FOR qualification> is optional. This syntax performs all the pairwise two sample Kolmogorov Smirnov tests.
KOLMOGOROVSMIRNOV TWO SAMPLE TEST Y1 Y2 SUBSET Y2 > 0
These parameters can be used in subsequent analysis.
By default, the KolmogorovSmirnov test is generated using all the points. When the number of points gets large, this can result in this command taking a very long time. Computing this test for a specified number of percentiles of the data allows this command to be executed quickly without sacrificing too much information.
The word test in the command is optional. TWO can be entered as 2. Some examples,
KS 2 SAMPLE Y1 Y2 KS TWO SAMPLE TEST Y1 Y2
Press, Teukolsky, Vetterling, and Flannery (1992), "Numerical Recipes in Fortan: The Art of Scientific Computing," Second Edition, Cambridge University Press, pp. 614622.
2011/03: If more than two variables given, perform all pairwise tests 2016/06: Added support for SET TWO SAMPLE TEST NUMBER OF PERCENTILES 2016/06: Added KS as synonym for KOLMOGOROV SMIRNOV SKIP 25 READ AUTO83B.DAT Y1 Y2 . DELETE Y2 SUBSET Y2 < 0 SET WRITE DECIMALS 4 KOLMOGOROVSMIRNOPV TWO SAMPLE TEST Y1 Y2The following output is generated. KolmogorovSmirnov Two Sample Test First Response Variable: Y1 Second Response Variable: Y2 H0: The Two Samples Come From the Same (Unspecified) Distribution Ha: The Two Samples Come From Different Distributions Sample One Summary Statistics: Number of Observations: 249 Sample Mean: 20.1446 Sample Standard Deviation: 6.4147 Sample Minimum: 9.0000 Sample Maximum: 39.0000 Sample Two Summary Statistics: Number of Observations: 79 Sample Mean: 30.4810 Sample Standard Deviation: 6.1077 Sample Minimum: 18.0000 Sample Maximum: 47.0000 Test Statistic Value: 0.6003 Conclusions (Upper 1Tailed Test)  Null Null Significance Test Critical Hypothesis Hypothesis Level Statistic Region (>=) Conclusion  Same 90.0% 0.6003 0.1575 REJECT Same 95.0% 0.6003 0.1756 REJECT Same 99.0% 0.6003 0.2105 REJECTProgram 2: let y1 = norm rand numb for i = 1 1 50 let y2 = norm rand numb for i = 1 1 62 let y3 = norm rand numb for i = 1 1 45 . let y2 = 1.7*y2 let y3 = 0.7*y3 . set write decimals 5 . two sample kolmogorov smirnov test y1 y2 y3The following output is generated. KolmogorovSmirnov Two Sample Test First Response Variable: Y1 Second Response Variable: Y2 H0: The Two Samples Come From the Same (Unspecified) Distribution Ha: The Two Samples Come From Different Distributions Sample One Summary Statistics: Number of Observations: 50 Sample Mean: 0.00822 Sample Standard Deviation: 0.71196 Sample Minimum: 2.01524 Sample Maximum: 1.58788 Sample Two Summary Statistics: Number of Observations: 62 Sample Mean: 0.29060 Sample Standard Deviation: 1.94815 Sample Minimum: 5.87855 Sample Maximum: 3.41010 Test Statistic Value: 0.28645 Conclusions (Upper 1Tailed Test)  Null Null Significance Test Critical Hypothesis Hypothesis Level Statistic Region (>=) Conclusion  Same 90.0% 0.28645 0.23189 REJECT Same 95.0% 0.28645 0.25850 REJECT Same 99.0% 0.28645 0.30982 ACCEPT KolmogorovSmirnov Two Sample Test First Response Variable: Y1 Second Response Variable: Y3 H0: The Two Samples Come From the Same (Unspecified) Distribution Ha: The Two Samples Come From Different Distributions Sample One Summary Statistics: Number of Observations: 50 Sample Mean: 0.00822 Sample Standard Deviation: 0.71196 Sample Minimum: 2.01524 Sample Maximum: 1.58788 Sample Two Summary Statistics: Number of Observations: 45 Sample Mean: 0.11118 Sample Standard Deviation: 0.70195 Sample Minimum: 2.21551 Sample Maximum: 1.29633 Test Statistic Value: 0.12222 Conclusions (Upper 1Tailed Test)  Null Null Significance Test Critical Hypothesis Hypothesis Level Statistic Region (>=) Conclusion  Same 90.0% 0.12222 0.25069 ACCEPT Same 95.0% 0.12222 0.27945 ACCEPT Same 99.0% 0.12222 0.33493 ACCEPT KolmogorovSmirnov Two Sample Test First Response Variable: Y2 Second Response Variable: Y3 H0: The Two Samples Come From the Same (Unspecified) Distribution Ha: The Two Samples Come From Different Distributions Sample One Summary Statistics: Number of Observations: 62 Sample Mean: 0.29060 Sample Standard Deviation: 1.94815 Sample Minimum: 5.87855 Sample Maximum: 3.41010 Sample Two Summary Statistics: Number of Observations: 45 Sample Mean: 0.11118 Sample Standard Deviation: 0.70195 Sample Minimum: 2.21551 Sample Maximum: 1.29633 Test Statistic Value: 0.24373 Conclusions (Upper 1Tailed Test)  Null Null Significance Test Critical Hypothesis Hypothesis Level Statistic Region (>=) Conclusion  Same 90.0% 0.24373 0.23892 REJECT Same 95.0% 0.24373 0.26634 ACCEPT Same 99.0% 0.24373 0.31921 ACCEPT . let stat = two sample kolm smir test y1 y2 let cv95 = two sample kolm smir test critical value y1 y2 let alpha = 0.9 let cv90 = two sample kolm smir test critical value y1 y2 let alpha = 0.99 let cv99 = two sample kolm smir test critical value y1 y2The following output is generated. PARAMETERS AND CONSTANTS STAT  0.28645 CV95  0.25850 CV90  0.23189 CV99  0.30982  
Privacy
Policy/Security Notice
NIST is an agency of the U.S. Commerce Department.
Date created: 6/5/2001 