comparison gnv-artifacts/src/main/java/de/intevation/gnv/statistics/AbstractStatistics.java @ 875:5e9efdda6894

merged gnv-artifacts/1.0
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:13:56 +0200
parents 2423cefe7d39
children f953c9a559d8
comparison
equal deleted inserted replaced
722:bb3ffe7d719e 875:5e9efdda6894
1 package de.intevation.gnv.statistics;
2
3 import org.apache.commons.math.stat.descriptive.DescriptiveStatistics;
4
5 import org.apache.commons.math.stat.regression.SimpleRegression;
6
7 import org.apache.log4j.Logger;
8
9 /**
10 * An abstract implementation of <code>Statistics</code> with a default
11 * implementation of the {@link #generateStatisticsValues(org.apache.commons.math.stat.descriptive.DescriptiveStatistics, org.apache.commons.math.stat.regression.SimpleRegression, java.lang.String)}
12 * method.
13 *
14 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
15 */
16 public abstract class AbstractStatistics
17 implements Statistics
18 {
19 private static Logger log = Logger.getLogger(
20 AbstractStatistics.class);
21
22 public AbstractStatistics() {
23 }
24
25 /**
26 * This method takes a statistics object and puts relevant values into a
27 * <code>StatisticSet</code>.
28 *
29 * @param lStatistics A statistics object.
30 * @param lRegression A simple regression.
31 * @param statisticName Name for the resulting statistic.
32 * @return a set of statistics.
33 */
34 protected StatisticSet generateStatisticsValues(
35 DescriptiveStatistics lStatistics,
36 SimpleRegression lRegression,
37 String statisticName
38 ) {
39 StatisticSet statisticSet = new StatisticSet(statisticName);
40
41 statisticSet.addStatistic(
42 new Statistic(
43 "gnviewer.statistics.descriptive.arithmeticMean",
44 lStatistics.getMean()));
45
46 statisticSet.addStatistic(
47 new Statistic(
48 "gnviewer.statistics.descriptive.kurtosis",
49 lStatistics.getKurtosis()));
50
51 statisticSet.addStatistic(
52 new Statistic(
53 "gnviewer.statistics.descriptive.max",
54 lStatistics.getMax()));
55
56 statisticSet.addStatistic(
57 new Statistic(
58 "gnviewer.statistics.descriptive.min",
59 lStatistics.getMin()));
60
61 statisticSet.addStatistic(
62 new Statistic(
63 "gnviewer.statistics.descriptive.n",
64 lStatistics.getN()));
65
66 statisticSet.addStatistic(
67 new Statistic(
68 "gnviewer.statistics.descriptive.percentile.90",
69 lStatistics.getPercentile(90)));
70
71 statisticSet.addStatistic(
72 new Statistic(
73 "gnviewer.statistics.descriptive.percentile.75",
74 lStatistics.getPercentile(75)));
75
76 statisticSet.addStatistic(
77 new Statistic(
78 "gnviewer.statistics.descriptive.percentile.50",
79 lStatistics.getPercentile(50)));
80
81 statisticSet.addStatistic(
82 new Statistic(
83 "gnviewer.statistics.descriptive.percentile.10",
84 lStatistics.getPercentile(10)));
85
86 statisticSet.addStatistic(
87 new Statistic(
88 "gnviewer.statistics.descriptive.deviation",
89 lStatistics.getStandardDeviation()));
90
91 statisticSet.addStatistic(
92 new Statistic(
93 "gnviewer.statistics.descriptive.variance",
94 lStatistics.getVariance()));
95
96 statisticSet.addStatistic(
97 new Statistic(
98 "gnviewer.statistics.descriptive.intercept",
99 lRegression.getIntercept()));
100
101 statisticSet.addStatistic(
102 new Statistic(
103 "gnviewer.statistics.descriptive.slope",
104 lRegression.getSlope()));
105
106 return statisticSet;
107 }
108 }
109 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
110

http://dive4elements.wald.intevation.org