EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.probfunction.math.apache.distribution]

COVERAGE SUMMARY FOR SOURCE FILE [UniformIntDistributionImpl.java]

nameclass, %method, %block, %line, %
UniformIntDistributionImpl.java0%   (0/1)0%   (0/9)0%   (0/98)0%   (0/21)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class UniformIntDistributionImpl0%   (0/1)0%   (0/9)0%   (0/98)0%   (0/21)
UniformIntDistributionImpl (int, int): void 0%   (0/1)0%   (0/26)0%   (0/7)
cumulativeProbability (int): double 0%   (0/1)0%   (0/23)0%   (0/5)
getA (): int 0%   (0/1)0%   (0/3)0%   (0/1)
getB (): int 0%   (0/1)0%   (0/3)0%   (0/1)
getDomainLowerBound (double): int 0%   (0/1)0%   (0/3)0%   (0/1)
getDomainUpperBound (double): int 0%   (0/1)0%   (0/3)0%   (0/1)
getMean (): double 0%   (0/1)0%   (0/9)0%   (0/1)
getVariance (): double 0%   (0/1)0%   (0/12)0%   (0/1)
probability (int): double 0%   (0/1)0%   (0/16)0%   (0/3)

1/**
2 * 
3 */
4package de.uka.ipd.sdq.probfunction.math.apache.distribution;
5 
6import org.apache.commons.math.MathException;
7import org.apache.commons.math.distribution.AbstractIntegerDistribution;
8 
9/**
10 * @author joerg
11 *
12 */
13public class UniformIntDistributionImpl extends AbstractIntegerDistribution {
14 
15        
16        /**
17         * 
18         */
19        private static final long serialVersionUID = 4771624459254238355L;
20        int a,b;
21        int intCount;
22        
23        
24        public int getA() {
25                return a;
26        }
27 
28 
29        public int getB() {
30                return b;
31        }
32 
33        
34        
35        public UniformIntDistributionImpl(int a, int b) throws MathException
36        {
37                if(b<a)
38                        throw new MathException("Second value has to be greater than first value of interval");
39                
40                this.a = a;
41                this.b = b;
42                intCount = b - a + 1;
43                
44                
45        }
46        
47        
48        /* (non-Javadoc)
49         * @see org.apache.commons.math.distribution.AbstractIntegerDistribution#cumulativeProbability(int)
50         */
51        @Override
52        public double cumulativeProbability(int x) throws MathException {
53                if(x<a)
54                        return 0;
55                else if(x>b)
56                        return 1;
57                
58                return (x-a+1)/intCount;
59        }
60 
61        /* (non-Javadoc)
62         * @see org.apache.commons.math.distribution.AbstractIntegerDistribution#getDomainLowerBound(double)
63         */
64        @Override
65        protected int getDomainLowerBound(double p) {
66                return a;
67        }
68 
69        /* (non-Javadoc)
70         * @see org.apache.commons.math.distribution.AbstractIntegerDistribution#getDomainUpperBound(double)
71         */
72        @Override
73        protected int getDomainUpperBound(double p) {
74                return b;
75        }
76 
77        /* (non-Javadoc)
78         * @see org.apache.commons.math.distribution.IntegerDistribution#probability(int)
79         */
80        @Override
81        public double probability(int x) {
82                if(x<a||x>b)
83                        return 0;
84                
85                return 1/intCount;
86        }
87        
88        public double getMean()
89        {
90                return (a+b)/2;
91        }
92        
93        public double getVariance()
94        {
95                return (-1.0*intCount*intCount)/12.0;
96        }
97 
98}

[all classes][de.uka.ipd.sdq.probfunction.math.apache.distribution]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov