1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.math.distribution;
18
19
20
21
22
23
24
25
26 public class PascalDistributionTest extends IntegerDistributionAbstractTest {
27
28
29
30
31
32 public PascalDistributionTest(String name) {
33 super(name);
34 }
35
36
37
38
39 @Override
40 public IntegerDistribution makeDistribution() {
41 return new PascalDistributionImpl(10,0.70);
42 }
43
44
45 @Override
46 public int[] makeDensityTestPoints() {
47 return new int[] {-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
48 }
49
50
51 @Override
52 public double[] makeDensityTestValues() {
53 return new double[] {0d, 0.02824d, 0.08474d, 0.13982d,
54 0.16779d, 0.16359d, 0.1374d, 0.10306d, 0.070673d, 0.04505d, 0.02703d, 0.01540d, 0.0084};
55 }
56
57
58 @Override
59 public int[] makeCumulativeTestPoints() {
60 return makeDensityTestPoints();
61 }
62
63
64 @Override
65 public double[] makeCumulativeTestValues() {
66 return new double[] {0d, 0.02824d, 0.11299d, 0.25281d, 0.42060d, 0.58420d,
67 0.72162d, 0.82468d, 0.89535d, 0.94041d, 0.967446d, 0.98285, 0.99125d};
68 }
69
70
71 @Override
72 public double[] makeInverseCumulativeTestPoints() {
73 return new double[] {0, 0.001d, 0.010d, 0.025d, 0.050d, 0.100d, 0.999d,
74 0.990d, 0.975d, 0.950d, 0.900d, 1};
75 }
76
77
78 @Override
79 public int[] makeInverseCumulativeTestValues() {
80 return new int[] {-1, -1, -1, -1, 0, 0, 13, 10, 9, 8, 7, Integer.MAX_VALUE};
81 }
82
83
84
85
86 public void testDegenerate0() throws Exception {
87 setDistribution(new PascalDistributionImpl(5,0.0d));
88 setCumulativeTestPoints(new int[] {-1, 0, 1, 5, 10 });
89 setCumulativeTestValues(new double[] {0d, 0d, 0d, 0d, 0d});
90 setDensityTestPoints(new int[] {-1, 0, 1, 10, 11});
91 setDensityTestValues(new double[] {0d, 0d, 0d, 0d, 0d});
92 setInverseCumulativeTestPoints(new double[] {0.1d, 0.5d});
93 setInverseCumulativeTestValues(new int[] {Integer.MAX_VALUE - 1, Integer.MAX_VALUE - 1});
94 verifyDensities();
95 verifyCumulativeProbabilities();
96 verifyInverseCumulativeProbabilities();
97 }
98
99
100 public void testDegenerate1() throws Exception {
101 setDistribution(new PascalDistributionImpl(5,1.0d));
102 setCumulativeTestPoints(new int[] {-1, 0, 1, 2, 5, 10 });
103 setCumulativeTestValues(new double[] {0d, 1d, 1d, 1d, 1d, 1d});
104 setDensityTestPoints(new int[] {-1, 0, 1, 2, 5, 10});
105 setDensityTestValues(new double[] {0d, 1d, 0d, 0d, 0d, 0d});
106 setInverseCumulativeTestPoints(new double[] {0.1d, 0.5d});
107 setInverseCumulativeTestValues(new int[] {-1, -1});
108 verifyDensities();
109 verifyCumulativeProbabilities();
110 verifyInverseCumulativeProbabilities();
111 }
112 }