1 | package de.uka.ipd.sdq.statistics.independence.test; |
2 | |
3 | import java.util.List; |
4 | |
5 | import junit.framework.TestCase; |
6 | import de.uka.ipd.sdq.statistics.independence.IIndependenceTest; |
7 | import de.uka.ipd.sdq.statistics.independence.RunUpTest; |
8 | import de.uka.ipd.sdq.statistics.test.TestUtils; |
9 | |
10 | public class TestRunUpTest extends TestCase { |
11 | |
12 | private IIndependenceTest indTest; |
13 | |
14 | @Override |
15 | protected void setUp() throws Exception { |
16 | super.setUp(); |
17 | |
18 | this.indTest = new RunUpTest(); |
19 | } |
20 | |
21 | public void testDependence() { |
22 | int desiredLag = 2; |
23 | int numberOfSamples = indTest.getLowerSampleLimit(); |
24 | int repititions = 100; |
25 | |
26 | List<Double> samples = null; |
27 | int indepCnt = 0; |
28 | int depCnt = 0; |
29 | for (int i = 0; i < repititions; i++) { |
30 | samples = TestUtils.createSampleSequence(numberOfSamples, |
31 | desiredLag); |
32 | if (indTest.testIndependence(samples)) { |
33 | ++indepCnt; |
34 | } else { |
35 | ++depCnt; |
36 | } |
37 | } |
38 | |
39 | System.out.println("Dependent: " + depCnt + ", Independent: " |
40 | + indepCnt); |
41 | assertTrue(depCnt > indepCnt); |
42 | } |
43 | |
44 | public void testIndependence() { |
45 | int desiredLag = 1; |
46 | int numberOfSamples = indTest.getLowerSampleLimit(); |
47 | int repititions = 100; |
48 | |
49 | List<Double> samples = null; |
50 | int indepCnt = 0; |
51 | int depCnt = 0; |
52 | for (int i = 0; i < repititions; i++) { |
53 | samples = TestUtils.createSampleSequence(numberOfSamples, |
54 | desiredLag); |
55 | if (indTest.testIndependence(samples)) { |
56 | ++indepCnt; |
57 | } else { |
58 | ++depCnt; |
59 | } |
60 | } |
61 | |
62 | System.out.println("Dependent: " + depCnt + ", Independent: " |
63 | + indepCnt); |
64 | assertTrue(depCnt < indepCnt); |
65 | } |
66 | |
67 | } |