comparison gnv-artifacts/src/main/java/de/intevation/gnv/statistics/TimeseriesStatistics.java @ 454:04cfb4e3da4f

Refactored statistics classes a bit. Added class for vertical cross sections. gnv-artifacts/trunk@503 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 04 Jan 2010 15:20:14 +0000
parents bed9735adf84
children b1f5f2a8840f
comparison
equal deleted inserted replaced
453:537e663d6c0c 454:04cfb4e3da4f
40 * @version 1.0 40 * @version 1.0
41 * @serial 1.0 41 * @serial 1.0
42 * @see 42 * @see
43 * @since 06.12.2007 18:02:27 43 * @since 06.12.2007 18:02:27
44 */ 44 */
45 public class TimeseriesStatistics implements Statistics { 45 public class TimeseriesStatistics
46 extends AbstractStatistics
47 {
46 48
47 /** 49 /**
48 * Default Logging instance 50 * Default Logging instance
49 */ 51 */
50 private static Logger log = Logger.getLogger(TimeseriesStatistics.class); 52 private static Logger log = Logger.getLogger(TimeseriesStatistics.class);
51 53
52 /** 54 /**
53 * Constructor 55 * Constructor
54 */ 56 */
55 public TimeseriesStatistics() { 57 public TimeseriesStatistics() {
56 super();
57 } 58 }
58 59
59 /** 60 /**
60 * @see de.intevation.gnv.statistics.Statistics#calculateStatistics(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection) 61 * @see de.intevation.gnv.statistics.Statistics#calculateStatistics(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection)
61 */ 62 */
62 public Collection<StatisticSet> calculateStatistics( 63 public Collection<StatisticSet> calculateStatistics(
63 Collection<Result> resultSet, 64 Object result,
64 Collection<KeyValueDescibeData> parameters, 65 Collection<KeyValueDescibeData> parameters,
65 Collection<KeyValueDescibeData> measurements, 66 Collection<KeyValueDescibeData> measurements,
66 Collection<KeyValueDescibeData> dates 67 Collection<KeyValueDescibeData> dates
67 ) 68 )
68 throws StatisticsException { 69 throws StatisticsException {
69 70
71 if (!(result instanceof Collection)) {
72 return new ArrayList<StatisticSet>();
73 }
74
75 Collection<Result> resultSet = (Collection<Result>)result;
76
70 clearStatistics(); 77 clearStatistics();
78
71 DescriptiveStatistics lStatistics = null; 79 DescriptiveStatistics lStatistics = null;
72 SimpleRegression lRegression = null; 80 SimpleRegression lRegression = null;
73 Collection<StatisticSet> statisticSets = new ArrayList<StatisticSet>(); 81 Collection<StatisticSet> statisticSets = new ArrayList<StatisticSet>();
74 String break1, break2, break3; 82 String break1, break2, break3;
75 int lSeries = 1; 83 int lSeries = 1;
222 } 230 }
223 protected double calculateXOrdinateValue(Result previousRow, Result row) throws SQLException { 231 protected double calculateXOrdinateValue(Result previousRow, Result row) throws SQLException {
224 return new Double((row.getDate("XORDINATE")).getTime() / 1000 / 3600); 232 return new Double((row.getDate("XORDINATE")).getTime() / 1000 / 3600);
225 } 233 }
226 234
227 /**
228 * @param lStatistics
229 * @param lRegression
230 * @param lStats
231 * @param lSeries
232 */
233 private StatisticSet generateStatisticsValues(DescriptiveStatistics lStatistics,
234 SimpleRegression lRegression, String statisticName) {
235
236 StatisticSet statisticSet = new StatisticSet(statisticName);
237
238 statisticSet.addStatistic(new Statistic(
239 "gnviewer.statistics.descriptive.arithmeticMean", lStatistics
240 .getMean()));
241 statisticSet.addStatistic(new Statistic(
242 "gnviewer.statistics.descriptive.kurtosis", lStatistics
243 .getKurtosis()));
244 statisticSet.addStatistic(new Statistic("gnviewer.statistics.descriptive.max",
245 lStatistics.getMax()));
246 statisticSet.addStatistic(new Statistic("gnviewer.statistics.descriptive.min",
247 lStatistics.getMin()));
248 statisticSet.addStatistic(new Statistic("gnviewer.statistics.descriptive.n",
249 lStatistics.getN()));
250 statisticSet.addStatistic(new Statistic(
251 "gnviewer.statistics.descriptive.percentile.90", lStatistics
252 .getPercentile(90)));
253 statisticSet.addStatistic(new Statistic(
254 "gnviewer.statistics.descriptive.percentile.75", lStatistics
255 .getPercentile(75)));
256 statisticSet.addStatistic(new Statistic(
257 "gnviewer.statistics.descriptive.percentile.50", lStatistics
258 .getPercentile(50)));
259 statisticSet.addStatistic(new Statistic(
260 "gnviewer.statistics.descriptive.percentile.10", lStatistics
261 .getPercentile(10)));
262 statisticSet.addStatistic(new Statistic(
263 "gnviewer.statistics.descriptive.deviation", lStatistics
264 .getStandardDeviation()));
265 statisticSet.addStatistic(new Statistic(
266 "gnviewer.statistics.descriptive.variance", lStatistics
267 .getVariance()));
268 statisticSet.addStatistic(new Statistic(
269 "gnviewer.statistics.descriptive.intercept", lRegression
270 .getIntercept()));
271 statisticSet.addStatistic(new Statistic("gnviewer.statistics.descriptive.slope",
272 lRegression.getSlope()));
273 return statisticSet;
274 }
275 } 235 }

http://dive4elements.wald.intevation.org