1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package ubic.basecode.math;
16
17 import static org.junit.Assert.assertEquals;
18
19 import org.junit.Test;
20
21 import ubic.basecode.math.distribution.ProbabilityComputer;
22 import ubic.basecode.math.distribution.UniformProbabilityComputer;
23 import cern.colt.list.DoubleArrayList;
24
25
26
27
28
29 public class TestKSTest {
30
31
32 DoubleArrayList x = new DoubleArrayList( new double[] { 0.42084388, 0.08428030, 0.51525081, 0.02165163, 0.99627802,
33 0.79237273, 0.52478154, 0.21394388, 0.19654006, 0.88131869 } );
34
35
36 DoubleArrayList y = new DoubleArrayList( new double[] { -0.09503411, 2.33677197, 0.61934707, 0.83549049,
37 0.09643316, -0.57449861, -1.40573974, 0.51279445, -0.09593008, 1.48125008 } );
38
39 @Test
40 public void testKSTestOneSample() {
41
42
43
44
45
46 ProbabilityComputer ps = new UniformProbabilityComputer();
47 double actualReturn = KSTest.oneSample( y, ps );
48 double expectedReturn = 0.07698;
49
50 assertEquals( 0.4036, KSTest.oneSampleStatistic( y, ps ), 0.001 );
51
52 assertEquals( expectedReturn, actualReturn, 0.0001 );
53 }
54
55
56
57
58 @Test
59 public void testKSTestTwoSample() {
60 double actualReturn = KSTest.twoSample( x, y );
61 double expectedReturn = 0.4175;
62
63 assertEquals( 0.40, KSTest.twoSampleStatistic( x, y ), 0.001 );
64
65 assertEquals( expectedReturn, actualReturn, 0.0001 );
66 }
67
68 }