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 [UniformDistributionImpl.java]

nameclass, %method, %block, %line, %
UniformDistributionImpl.java0%   (0/1)0%   (0/9)0%   (0/82)0%   (0/18)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class UniformDistributionImpl0%   (0/1)0%   (0/9)0%   (0/82)0%   (0/18)
UniformDistributionImpl (double, double): void 0%   (0/1)0%   (0/20)0%   (0/6)
cumulativeProbability (double): double 0%   (0/1)0%   (0/25)0%   (0/5)
getA (): double 0%   (0/1)0%   (0/3)0%   (0/1)
getB (): double 0%   (0/1)0%   (0/3)0%   (0/1)
getDomainLowerBound (double): double 0%   (0/1)0%   (0/3)0%   (0/1)
getDomainUpperBound (double): double 0%   (0/1)0%   (0/3)0%   (0/1)
getInitialDomain (double): double 0%   (0/1)0%   (0/3)0%   (0/1)
getMean (): double 0%   (0/1)0%   (0/8)0%   (0/1)
getVariance (): double 0%   (0/1)0%   (0/14)0%   (0/1)

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

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