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

COVERAGE SUMMARY FOR SOURCE FILE [SampleMeanEstimator.java]

nameclass, %method, %block, %line, %
SampleMeanEstimator.java0%   (0/1)0%   (0/5)0%   (0/112)0%   (0/24)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SampleMeanEstimator0%   (0/1)0%   (0/5)0%   (0/112)0%   (0/24)
<static initializer> 0%   (0/1)0%   (0/8)0%   (0/1)
SampleMeanEstimator (): void 0%   (0/1)0%   (0/6)0%   (0/2)
SampleMeanEstimator (IContinousPDFFactory): void 0%   (0/1)0%   (0/15)0%   (0/4)
estimateConfidence (List, double): ConfidenceInterval 0%   (0/1)0%   (0/59)0%   (0/13)
estimatePoint (List): double 0%   (0/1)0%   (0/24)0%   (0/4)

1package de.uka.ipd.sdq.statistics.estimation;
2 
3import java.util.List;
4 
5import de.uka.ipd.sdq.probfunction.math.IContinousPDFFactory;
6import de.uka.ipd.sdq.probfunction.math.IStudentTDistribution;
7import de.uka.ipd.sdq.probfunction.math.apache.impl.PDFFactory;
8 
9/**
10 * Estimator for the sample mean.
11 * 
12 * @author Philipp Merkle
13 *
14 */
15public class SampleMeanEstimator implements IPointEstimator, IConfidenceEstimator {
16 
17    private IContinousPDFFactory pdfFactory;
18 
19    public SampleMeanEstimator() {
20        this(new PDFFactory());
21    }
22 
23    public SampleMeanEstimator(IContinousPDFFactory pdfFactory) {
24        assert pdfFactory != null : "The passed PDF factory may not be null.";
25        this.pdfFactory = pdfFactory;
26    }
27    
28        @Override
29        public ConfidenceInterval estimateConfidence(List<Double> samples,
30                        double level) {
31                int degreesOfFreedom = samples.size() - 1;
32                if (degreesOfFreedom > 0){
33                        IStudentTDistribution dist = this.pdfFactory.createStudentTDistribution(degreesOfFreedom);
34                        double upperQuantile = dist.inverseF(level);
35 
36                        // calculate sample standard deviation
37                        double stdDev = Math.sqrt(new SampleVarianceEstimator()
38                        .estimatePoint(samples));
39 
40                        // calculate sample mean
41                        double mean = estimatePoint(samples);
42 
43                        // calculate confidence interval
44                        double lowerBound = mean - upperQuantile * stdDev
45                        / Math.sqrt(samples.size());
46                        double upperBound = mean + upperQuantile * stdDev
47                        / Math.sqrt(samples.size());
48 
49                        return new ConfidenceInterval(mean, lowerBound, upperBound, level);
50                } else {
51                        return null;
52                }
53        }
54 
55        @Override
56        public double estimatePoint(List<Double> samples) {
57                double sum = 0;
58                for (Double sample : samples) {
59                        sum += sample;
60                }
61                return sum / samples.size();
62        }
63}

[all classes][de.uka.ipd.sdq.statistics.estimation]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov