rio - gsdir work...
[jalview.git] / forester / java / src / org / forester / util / BasicDescriptiveStatistics.java
index 699526f..538f6a1 100644 (file)
@@ -7,7 +7,7 @@
 // Copyright (C) 2008-2009 Christian M. Zmasek
 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
 // All rights reserved
-// 
+//
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
@@ -17,7 +17,7 @@
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 // Lesser General Public License for more details.
-// 
+//
 // You should have received a copy of the GNU Lesser General Public
 // License along with this library; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
@@ -39,14 +39,21 @@ public class BasicDescriptiveStatistics implements DescriptiveStatistics {
     private double       _max;
     private double       _sigma;
     private boolean      _recalc_sigma;
+    private String       _desc;
 
     public BasicDescriptiveStatistics() {
         init();
     }
 
+    public BasicDescriptiveStatistics( final String desc ) {
+        init();
+        setDescription( desc );
+    }
+
     /* (non-Javadoc)
      * @see org.forester.util.DescriptiveStatisticsI#addValue(double)
      */
+    @Override
     public void addValue( final double d ) {
         _recalc_sigma = true;
         _sum += d;
@@ -62,6 +69,7 @@ public class BasicDescriptiveStatistics implements DescriptiveStatistics {
     /* (non-Javadoc)
      * @see org.forester.util.DescriptiveStatisticsI#arithmeticMean()
      */
+    @Override
     public double arithmeticMean() {
         validate();
         return getSum() / getN();
@@ -70,6 +78,7 @@ public class BasicDescriptiveStatistics implements DescriptiveStatistics {
     /* (non-Javadoc)
      * @see org.forester.util.DescriptiveStatisticsI#asSummary()
      */
+    @Override
     public String asSummary() {
         if ( getN() > 1 ) {
             return arithmeticMean() + DescriptiveStatistics.PLUS_MINUS + sampleStandardDeviation() + " [" + getMin()
@@ -83,6 +92,7 @@ public class BasicDescriptiveStatistics implements DescriptiveStatistics {
     /* (non-Javadoc)
      * @see org.forester.util.DescriptiveStatisticsI#coefficientOfVariation()
      */
+    @Override
     public double coefficientOfVariation() {
         validate();
         return ( sampleStandardDeviation() / arithmeticMean() );
@@ -91,6 +101,7 @@ public class BasicDescriptiveStatistics implements DescriptiveStatistics {
     /* (non-Javadoc)
      * @see org.forester.util.DescriptiveStatisticsI#getDataAsDoubleArray()
      */
+    @Override
     public double[] getDataAsDoubleArray() {
         validate();
         final double[] data_array = new double[ getN() ];
@@ -103,6 +114,7 @@ public class BasicDescriptiveStatistics implements DescriptiveStatistics {
     /* (non-Javadoc)
      * @see org.forester.util.DescriptiveStatisticsI#getMax()
      */
+    @Override
     public double getMax() {
         validate();
         return _max;
@@ -111,6 +123,7 @@ public class BasicDescriptiveStatistics implements DescriptiveStatistics {
     /* (non-Javadoc)
      * @see org.forester.util.DescriptiveStatisticsI#getMin()
      */
+    @Override
     public double getMin() {
         validate();
         return _min;
@@ -119,6 +132,7 @@ public class BasicDescriptiveStatistics implements DescriptiveStatistics {
     /* (non-Javadoc)
      * @see org.forester.util.DescriptiveStatisticsI#getN()
      */
+    @Override
     public int getN() {
         return _data.size();
     }
@@ -126,14 +140,14 @@ public class BasicDescriptiveStatistics implements DescriptiveStatistics {
     /* (non-Javadoc)
      * @see org.forester.util.DescriptiveStatisticsI#getSum()
      */
+    @Override
     public double getSum() {
         validate();
         return _sum;
     }
 
-    /* (non-Javadoc)
-     * @see org.forester.util.DescriptiveStatisticsI#getSummaryAsString()
-     */
+  
+    @Override
     public String getSummaryAsString() {
         validate();
         final double mean = arithmeticMean();
@@ -141,9 +155,8 @@ public class BasicDescriptiveStatistics implements DescriptiveStatistics {
         return "" + mean + ( ( char ) 177 ) + sd + " [" + getMin() + "..." + getMax() + "]";
     }
 
-    /* (non-Javadoc)
-     * @see org.forester.util.DescriptiveStatisticsI#getValue(int)
-     */
+   
+    @Override
     public double getValue( final int index ) {
         validate();
         return ( ( ( _data.get( index ) ) ).doubleValue() );
@@ -156,11 +169,13 @@ public class BasicDescriptiveStatistics implements DescriptiveStatistics {
         _max = -Double.MAX_VALUE;
         _sigma = 0.0;
         _recalc_sigma = true;
+        _desc = "";
     }
 
     /* (non-Javadoc)
      * @see org.forester.util.DescriptiveStatisticsI#median()
      */
+    @Override
     public double median() {
         validate();
         double median = 0.0;
@@ -185,6 +200,7 @@ public class BasicDescriptiveStatistics implements DescriptiveStatistics {
     /* (non-Javadoc)
      * @see org.forester.util.DescriptiveStatisticsI#midrange()
      */
+    @Override
     public double midrange() {
         validate();
         return ( _min + _max ) / 2.0;
@@ -193,6 +209,7 @@ public class BasicDescriptiveStatistics implements DescriptiveStatistics {
     /* (non-Javadoc)
      * @see org.forester.util.DescriptiveStatisticsI#pearsonianSkewness()
      */
+    @Override
     public double pearsonianSkewness() {
         validate();
         final double mean = arithmeticMean();
@@ -204,6 +221,7 @@ public class BasicDescriptiveStatistics implements DescriptiveStatistics {
     /* (non-Javadoc)
      * @see org.forester.util.DescriptiveStatisticsI#sampleStandardDeviation()
      */
+    @Override
     public double sampleStandardDeviation() {
         return Math.sqrt( sampleVariance() );
     }
@@ -211,6 +229,7 @@ public class BasicDescriptiveStatistics implements DescriptiveStatistics {
     /* (non-Javadoc)
      * @see org.forester.util.DescriptiveStatisticsI#sampleStandardUnit(double)
      */
+    @Override
     public double sampleStandardUnit( final double value ) {
         validate();
         return BasicDescriptiveStatistics.sampleStandardUnit( value, arithmeticMean(), sampleStandardDeviation() );
@@ -219,6 +238,7 @@ public class BasicDescriptiveStatistics implements DescriptiveStatistics {
     /* (non-Javadoc)
      * @see org.forester.util.DescriptiveStatisticsI#sampleVariance()
      */
+    @Override
     public double sampleVariance() {
         validate();
         if ( getN() < 2 ) {
@@ -230,6 +250,7 @@ public class BasicDescriptiveStatistics implements DescriptiveStatistics {
     /* (non-Javadoc)
      * @see org.forester.util.DescriptiveStatisticsI#standardErrorOfMean()
      */
+    @Override
     public double standardErrorOfMean() {
         validate();
         return ( sampleStandardDeviation() / Math.sqrt( getN() ) );
@@ -238,6 +259,7 @@ public class BasicDescriptiveStatistics implements DescriptiveStatistics {
     /* (non-Javadoc)
      * @see org.forester.util.DescriptiveStatisticsI#sumDeviations()
      */
+    @Override
     public double sumDeviations() {
         validate();
         if ( _recalc_sigma ) {
@@ -337,4 +359,19 @@ public class BasicDescriptiveStatistics implements DescriptiveStatistics {
     public static double sampleStandardUnit( final double value, final double mean, final double sd ) {
         return ( value - mean ) / sd;
     }
+
+    @Override
+    public List<Double> getData() {
+        return _data;
+    }
+
+    @Override
+    public void setDescription( final String desc ) {
+        _desc = desc;
+    }
+
+    @Override
+    public String getDescription() {
+        return _desc;
+    }
 }