ingo@1115: /* ingo@1115: * Copyright (c) 2010 by Intevation GmbH ingo@1115: * ingo@1115: * This program is free software under the LGPL (>=v2.1) ingo@1115: * Read the file LGPL.txt coming with the software for details ingo@1115: * or visit http://www.gnu.org/licenses/ if it does not exist. ingo@1115: */ ingo@1115: sascha@454: package de.intevation.gnv.statistics; sascha@454: sascha@454: import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; sascha@454: sascha@454: import org.apache.commons.math.stat.regression.SimpleRegression; sascha@454: sascha@454: import org.apache.log4j.Logger; sascha@454: sascha@454: /** ingo@814: * An abstract implementation of Statistics with a default ingo@814: * implementation of the {@link #generateStatisticsValues(org.apache.commons.math.stat.descriptive.DescriptiveStatistics, org.apache.commons.math.stat.regression.SimpleRegression, java.lang.String)} ingo@814: * method. sascha@835: * sascha@780: * @author Sascha L. Teichmann sascha@454: */ sascha@454: public abstract class AbstractStatistics sascha@454: implements Statistics sascha@454: { sascha@454: private static Logger log = Logger.getLogger( sascha@454: AbstractStatistics.class); sascha@454: sascha@454: public AbstractStatistics() { sascha@454: } sascha@454: ingo@814: /** ingo@814: * This method takes a statistics object and puts relevant values into a ingo@814: * StatisticSet. ingo@814: * ingo@814: * @param lStatistics A statistics object. ingo@814: * @param lRegression A simple regression. ingo@814: * @param statisticName Name for the resulting statistic. ingo@814: * @return a set of statistics. ingo@814: */ sascha@454: protected StatisticSet generateStatisticsValues( sascha@454: DescriptiveStatistics lStatistics, sascha@778: SimpleRegression lRegression, sascha@454: String statisticName sascha@454: ) { sascha@454: StatisticSet statisticSet = new StatisticSet(statisticName); sascha@778: sascha@454: statisticSet.addStatistic( sascha@454: new Statistic( sascha@454: "gnviewer.statistics.descriptive.arithmeticMean", sascha@454: lStatistics.getMean())); sascha@454: sascha@454: statisticSet.addStatistic( sascha@454: new Statistic( sascha@778: "gnviewer.statistics.descriptive.kurtosis", sascha@454: lStatistics.getKurtosis())); sascha@454: sascha@454: statisticSet.addStatistic( sascha@454: new Statistic( sascha@454: "gnviewer.statistics.descriptive.max", sascha@454: lStatistics.getMax())); sascha@454: sascha@454: statisticSet.addStatistic( sascha@454: new Statistic( sascha@454: "gnviewer.statistics.descriptive.min", sascha@454: lStatistics.getMin())); sascha@454: sascha@454: statisticSet.addStatistic( sascha@454: new Statistic( sascha@454: "gnviewer.statistics.descriptive.n", sascha@454: lStatistics.getN())); sascha@454: sascha@454: statisticSet.addStatistic( sascha@454: new Statistic( sascha@454: "gnviewer.statistics.descriptive.percentile.90", sascha@454: lStatistics.getPercentile(90))); sascha@454: sascha@454: statisticSet.addStatistic( sascha@454: new Statistic( sascha@454: "gnviewer.statistics.descriptive.percentile.75", sascha@454: lStatistics.getPercentile(75))); sascha@454: sascha@454: statisticSet.addStatistic( sascha@454: new Statistic( sascha@454: "gnviewer.statistics.descriptive.percentile.50", sascha@454: lStatistics.getPercentile(50))); sascha@454: sascha@454: statisticSet.addStatistic( sascha@454: new Statistic( sascha@454: "gnviewer.statistics.descriptive.percentile.10", sascha@454: lStatistics.getPercentile(10))); sascha@454: sascha@454: statisticSet.addStatistic( sascha@454: new Statistic( sascha@454: "gnviewer.statistics.descriptive.deviation", sascha@454: lStatistics.getStandardDeviation())); sascha@454: sascha@454: statisticSet.addStatistic( sascha@454: new Statistic( sascha@454: "gnviewer.statistics.descriptive.variance", sascha@454: lStatistics.getVariance())); sascha@454: sascha@454: statisticSet.addStatistic( sascha@454: new Statistic( sascha@778: "gnviewer.statistics.descriptive.intercept", sascha@454: lRegression.getIntercept())); sascha@454: sascha@454: statisticSet.addStatistic( sascha@454: new Statistic( sascha@454: "gnviewer.statistics.descriptive.slope", sascha@454: lRegression.getSlope())); sascha@454: sascha@454: return statisticSet; sascha@454: } sascha@454: } sascha@454: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : sascha@454: