commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject cvs commit: jakarta-commons/math/src/test/org/apache/commons/math/random EmpiricalDistributionTest.java RandomDataTest.java ValueServerTest.java
Date Sun, 25 Jan 2004 21:30:42 GMT
psteitz     2004/01/25 13:30:42

  Modified:    math/src/java/org/apache/commons/math/stat
                        AbstractDescriptiveStatistics.java
                        DescriptiveStatistics.java
                        DescriptiveStatisticsImpl.java TestStatistic.java
                        TestStatisticImpl.java
               math/src/java/org/apache/commons/math/stat/univariate/moment
                        FirstMoment.java GeometricMean.java Kurtosis.java
                        Skewness.java Variance.java
               math/src/java/org/apache/commons/math/stat/univariate/rank
                        Max.java Min.java
               math/src/test/org/apache/commons/math/stat
                        CertifiedDataTest.java ListUnivariateImpl.java
                        ListUnivariateImplTest.java
                        StoreUnivariateImplTest.java TestStatisticTest.java
               math/src/test/org/apache/commons/math/stat/univariate
                        StorelessUnivariateStatisticAbstractTest.java
                        UnivariateImplTest.java
                        UnivariateStatisticAbstractTest.java
               math/src/java/org/apache/commons/math/random
                        EmpiricalDistribution.java
                        EmpiricalDistributionImpl.java ValueServer.java
               math/src/test/org/apache/commons/math/random
                        EmpiricalDistributionTest.java RandomDataTest.java
                        ValueServerTest.java
  Added:       math/src/java/org/apache/commons/math/stat
                        StatisticalSummary.java SummaryStatistics.java
                        SummaryStatisticsImpl.java
  Removed:     math/src/java/org/apache/commons/math/stat
                        AbstractStorelessDescriptiveStatistics.java
                        StorelessDescriptiveStatisticsImpl.java
  Log:
  Refactored statistical aggregates to separate stored, storeless implementations. Changed internal sample size counters to longs.
  
  Revision  Changes    Path
  1.3       +137 -18   jakarta-commons/math/src/java/org/apache/commons/math/stat/AbstractDescriptiveStatistics.java
  
  Index: AbstractDescriptiveStatistics.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/stat/AbstractDescriptiveStatistics.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractDescriptiveStatistics.java	18 Jan 2004 03:45:02 -0000	1.2
  +++ AbstractDescriptiveStatistics.java	25 Jan 2004 21:30:41 -0000	1.3
  @@ -55,40 +55,157 @@
   
   import java.util.Arrays;
   
  +import org.apache.commons.math.stat.univariate.moment.GeometricMean;
  +import org.apache.commons.math.stat.univariate.moment.Kurtosis;
  +import org.apache.commons.math.stat.univariate.moment.Mean;
  +import org.apache.commons.math.stat.univariate.moment.Skewness;
  +import org.apache.commons.math.stat.univariate.moment.Variance;
  +import org.apache.commons.math.stat.univariate.rank.Max;
  +import org.apache.commons.math.stat.univariate.rank.Min;
   import org.apache.commons.math.stat.univariate.rank.Percentile;
  +import org.apache.commons.math.stat.univariate.summary.Sum;
  +import org.apache.commons.math.stat.univariate.summary.SumOfSquares;
  +import org.apache.commons.math.stat.univariate.UnivariateStatistic;
   
   /**
  - * Extends {@link AbstractStorelessDescriptiveStatistics} to include univariate statistics
  - * that may require access to the full set of sample values. 
  + * Abstract superclass for DescriptiveStatistics implementations. 
  + * 
    * @version $Revision$ $Date$
    */
   public abstract class AbstractDescriptiveStatistics
  -    extends AbstractStorelessDescriptiveStatistics {
  -
  -    /** Percentile */
  -    protected Percentile percentile = new Percentile(50);
  +    extends DescriptiveStatistics {
           
       /**
        * Create an AbstractDescriptiveStatistics
        */
       public AbstractDescriptiveStatistics() {
  -        super();
       }
   
       /**
        * Create an AbstractDescriptiveStatistics with a specific Window
        * @param window WindowSIze for stat calculation
        */
  -    public AbstractDescriptiveStatistics(int window) {
  -        super(window);
  +    public AbstractDescriptiveStatistics(int window)  {
  +    	setWindowSize(window);
  +    }
  +
  +    /**
  +     * @see org.apache.commons.math.stat.DescriptiveStatistics#getSum()
  +     */
  +    public double getSum() {
  +    	return apply(new Sum());
  +    }
  +
  +    /**
  +     * @see org.apache.commons.math.stat.DescriptiveStatistics#getSumsq()
  +     */
  +    public double getSumsq() {
  +    	return apply(new SumOfSquares());
  +    }
  +
  +    /**
  +     * @see org.apache.commons.math.stat.DescriptiveStatistics#getMean()
  +     */
  +    public double getMean() {
  +    	return apply(new Mean());
  +    }
  +
  +    /**
  +    * @see org.apache.commons.math.stat.DescriptiveStatistics#getStandardDeviation()
  +     */
  +    public double getStandardDeviation() {
  +    	double stdDev = Double.NaN;
  +    	if (getN() > 0) {
  +    		if (getN() > 1) {
  +    			stdDev = Math.sqrt(getVariance());
  +    		} else {
  +    			stdDev = 0.0;
  +    		}
  +    	}
  +    	return (stdDev);
  +    }
  +
  +    /**
  +     * @see org.apache.commons.math.stat.DescriptiveStatistics#getVariance()
  +     */
  +    public double getVariance() {
  +    	return apply(new Variance());
  +    }
  +
  +    /**
  +     * @see org.apache.commons.math.stat.DescriptiveStatistics#getSkewness()
  +     */
  +    public double getSkewness() {
  +    	return apply(new Skewness());
  +    }
  +
  +    /**
  +      * @see org.apache.commons.math.stat.DescriptiveStatistics#getKurtosis()
  +     */
  +    public double getKurtosis() {
  +    	return apply(new Kurtosis());
       }
   
       /**
  -     * @see org.apache.commons.math.stat.DescriptiveStatistics#getPercentile(double)
  +     * @see org.apache.commons.math.stat.DescriptiveStatistics#getKurtosisClass()
  +     */
  +    public int getKurtosisClass() {
  +    	int kClass = MESOKURTIC;
  +
  +    	double kurtosis = getKurtosis();
  +    	if (kurtosis > 0) {
  +    		kClass = LEPTOKURTIC;
  +    	} else if (kurtosis < 0) {
  +    		kClass = PLATYKURTIC;
  +    	}
  +    	return (kClass);
  +    }
  +
  +    /**
  +     * @see org.apache.commons.math.stat.DescriptiveStatistics#getMax()
  +     */
  +    public double getMax() {
  +    	return apply(new Max());
  +    }
  +
  +    /**
  +     * @see org.apache.commons.math.stat.DescriptiveStatistics#getMin()
  +     */
  +    public double getMin() {
  +    	return apply(new Min());
  +    }
  +
  +    /**
  +     * @see org.apache.commons.math.stat.DescriptiveStatistics#getGeometricMean()
  +     */
  +    public double getGeometricMean() {
  +    	return apply(new GeometricMean());
  +    }
  +    
  +    /**
  +     * @see org.apache.commons.math.stat.DescriptiveStatistics#getPercentile()
        */
       public double getPercentile(double p) {
  -        percentile.setPercentile(p);
  -        return apply(percentile);
  +    	return apply(new Percentile(p));
  +    }
  +    
  +    /**
  +     * Generates a text report displaying
  +     * univariate statistics from values that
  +     * have been added.
  +     * @return String with line feeds displaying statistics
  +     */
  +    public String toString() {
  +    	StringBuffer outBuffer = new StringBuffer();
  +    	outBuffer.append("UnivariateImpl:\n");
  +    	outBuffer.append("n: " + getN() + "\n");
  +    	outBuffer.append("min: " + getMin() + "\n");
  +    	outBuffer.append("max: " + getMax() + "\n");
  +    	outBuffer.append("mean: " + getMean() + "\n");
  +    	outBuffer.append("std dev: " + getStandardDeviation() + "\n");
  +    	outBuffer.append("skewness: " + getSkewness() + "\n");
  +    	outBuffer.append("kurtosis: " + getKurtosis() + "\n");
  +    	return outBuffer.toString();
       }
       
       /**
  @@ -101,7 +218,7 @@
       }
       
       /**
  -     * @see org.apache.commons.math.stat.Univariate#addValue(double)
  +     * @see org.apache.commons.math.stat.DescriptiveStatistics#addValue(double)
        */
       public abstract void addValue(double value);
   
  @@ -110,12 +227,14 @@
        */
       public abstract double[] getValues();
   
  -
       /**
        * @see org.apache.commons.math.stat.DescriptiveStatistics#getElement(int)
        */
       public abstract double getElement(int index);
  -
  -
  -
  +    
  +    /**
  +      * @see org.apache.commons.math.stat.DescriptiveStatistics#apply(UnivariateStatistic)
  +     */
  +    public abstract double apply(UnivariateStatistic stat);
  +    
   }
  
  
  
  1.4       +12 -3     jakarta-commons/math/src/java/org/apache/commons/math/stat/DescriptiveStatistics.java
  
  Index: DescriptiveStatistics.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/stat/DescriptiveStatistics.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DescriptiveStatistics.java	18 Jan 2004 03:45:02 -0000	1.3
  +++ DescriptiveStatistics.java	25 Jan 2004 21:30:41 -0000	1.4
  @@ -57,12 +57,14 @@
   
   import org.apache.commons.discovery.tools.DiscoverClass;
   
  +import org.apache.commons.math.stat.univariate.UnivariateStatistic;
  +
   /**
    * Abstract factory class for univariate statistical summaries.
    * 
    * @version $Revision$ $Date$
    */
  -public abstract class DescriptiveStatistics implements Serializable{
  +public abstract class DescriptiveStatistics implements Serializable, StatisticalSummary {
   
   	/**
   	 * Create an instance of a <code>DescriptiveStatistics</code>
  @@ -195,7 +197,7 @@
   	 * Returns the number of available values
   	 * @return The number of available values
   	 */
  -	public abstract int getN();
  +	public abstract long getN();
   
   	/**
   	 * Returns the sum of the values that have been added to Univariate.
  @@ -279,5 +281,12 @@
        * values
        */
   	public abstract double getPercentile(double p);
  +	
  +	/**
  +	 * Apply the given statistic to the data associated with this set of statistics.
  +	 * @param stat the statistic to apply
  +	 * @return the computed value of the statistic.
  +	 */
  +	public abstract double apply(UnivariateStatistic stat);
   
   }
  
  
  
  1.3       +38 -12    jakarta-commons/math/src/java/org/apache/commons/math/stat/DescriptiveStatisticsImpl.java
  
  Index: DescriptiveStatisticsImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/stat/DescriptiveStatisticsImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DescriptiveStatisticsImpl.java	19 Nov 2003 03:28:23 -0000	1.2
  +++ DescriptiveStatisticsImpl.java	25 Jan 2004 21:30:41 -0000	1.3
  @@ -1,7 +1,7 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2003 The Apache Software Foundation.  All rights
  + * Copyright (c) 2003-2004 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -55,7 +55,9 @@
   
   import java.io.Serializable;
   
  -import org.apache.commons.math.stat.univariate.*;
  +import java.util.Arrays;
  +
  +import org.apache.commons.math.stat.univariate.UnivariateStatistic;
   import org.apache.commons.math.util.ContractableDoubleArray;
   
   /**
  @@ -63,18 +65,34 @@
    */
   public class DescriptiveStatisticsImpl extends AbstractDescriptiveStatistics implements Serializable {
   
  -    /** A contractable double array is used.  memory is reclaimed when 
  -     * the storage of the array becomes too empty.
  +	/** hold the window size **/
  +	protected int windowSize = INFINITE_WINDOW;
  +    
  +    /** 
  +     *  Stored data values
        */
       protected ContractableDoubleArray eDA;
   
       /**
  -     * Construct a DescriptiveStatisticsImpl
  +     * Construct a DescriptiveStatisticsImpl with infinite window
        */
       public DescriptiveStatisticsImpl() {
  +    	super();
           eDA = new ContractableDoubleArray();
       }
  +    
  +    /**
  +     * Construct a DescriptiveStatisticsImpl with finite window
  +     */
  +    public DescriptiveStatisticsImpl(int window) {
  +    	super(window);
  +    	eDA = new ContractableDoubleArray();
  +    }
   
  +    public int getWindowSize() {
  +    	return windowSize;
  +    }
  +    
       /**
        * @see org.apache.commons.math.stat.DescriptiveStatistics#getValues()
        */
  @@ -89,6 +107,15 @@
               eDA.getNumElements());
           return copiedArray;
       }
  +    
  +    /**
  +     * @see org.apache.commons.math.stat.DescriptiveStatistics#getSortedValues()
  +     */
  +    public double[] getSortedValues() {
  +    	double[] sort = getValues();
  +    	Arrays.sort(sort);
  +    	return sort;
  +    }
   
       /**
        * @see org.apache.commons.math.stat.DescriptiveStatistics#getElement(int)
  @@ -98,14 +125,14 @@
       }
   
       /**
  -     * @see org.apache.commons.math.stat.Univariate#getN()
  +     * @see org.apache.commons.math.stat.DescriptiveStatistics#getN()
        */
  -    public int getN() {
  +    public long getN() {
           return eDA.getNumElements();
       }
   
       /**
  -     * @see org.apache.commons.math.stat.Univariate#addValue(double)
  +     * @see org.apache.commons.math.stat.DescriptiveStatistics#addValue(double)
        */
       public synchronized void addValue(double v) {
           if (windowSize != INFINITE_WINDOW) {
  @@ -125,15 +152,14 @@
       }
   
       /**
  -     * @see org.apache.commons.math.stat.Univariate#clear()
  +     * @see org.apache.commons.math.stat.DescriptiveStatistics#clear()
        */
       public synchronized void clear() {
  -        super.clear();
           eDA.clear();
       }
   
       /**
  -     * @see org.apache.commons.math.stat.Univariate#setWindowSize(int)
  +     * @see org.apache.commons.math.stat.DescriptiveStatistics#setWindowSize(int)
        */
       public synchronized void setWindowSize(int windowSize) {
           this.windowSize = windowSize;
  
  
  
  1.11      +14 -14    jakarta-commons/math/src/java/org/apache/commons/math/stat/TestStatistic.java
  
  Index: TestStatistic.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/stat/TestStatistic.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- TestStatistic.java	19 Nov 2003 03:22:54 -0000	1.10
  +++ TestStatistic.java	25 Jan 2004 21:30:41 -0000	1.11
  @@ -1,7 +1,7 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2003 The Apache Software Foundation.  All rights
  + * Copyright (c) 2003-2004 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -356,7 +356,7 @@
        * @return t statistic
        * @throws IllegalArgumentException if the precondition is not met
        */
  -    double t(double mu, DescriptiveStatistics sampleStats) 
  +    double t(double mu, StatisticalSummary sampleStats) 
           throws IllegalArgumentException, MathException;
       
       /**
  @@ -377,7 +377,7 @@
        * @return t statistic
        * @throws IllegalArgumentException if the precondition is not met
        */
  -    double t(DescriptiveStatistics sampleStats1, DescriptiveStatistics sampleStats2) 
  +    double t(StatisticalSummary sampleStats1, StatisticalSummary sampleStats2) 
           throws IllegalArgumentException, MathException;
       
       /**
  @@ -406,12 +406,12 @@
        * at least 5 observations.
        * </li></ul>
        *
  -     * @param sampleStats1 DescriptiveStatistics describing data from the first sample
  -     * @param sampleStats2 DescriptiveStatistics describing data from the second sample
  +     * @param sampleStats1 StatisticalSummary describing data from the first sample
  +     * @param sampleStats2 StatisticalSummary describing data from the second sample
        * @return p-value for t-test
        * @throws IllegalArgumentException if the precondition is not met
        */
  -    double tTest(DescriptiveStatistics sampleStats1, DescriptiveStatistics sampleStats2)
  +    double tTest(StatisticalSummary sampleStats1, StatisticalSummary sampleStats2)
           throws IllegalArgumentException, MathException;
       
       /**
  @@ -453,14 +453,14 @@
        * <li> <code> 0 < alpha < 0.5 </code>
        * </li></ul>
        *
  -     * @param sampleStats1 DescriptiveStatistics describing sample data values
  -     * @param sampleStats2 DescriptiveStatistics describing sample data values
  +     * @param sampleStats1 StatisticalSummary describing sample data values
  +     * @param sampleStats2 StatisticalSummary describing sample data values
        * @param alpha significance level of the test
        * @return true if the null hypothesis can be rejected with 
        * confidence 1 - alpha
        * @throws IllegalArgumentException if the preconditions are not met
        */
  -    boolean tTest(DescriptiveStatistics sampleStats1, DescriptiveStatistics sampleStats2, 
  +    boolean tTest(StatisticalSummary sampleStats1, StatisticalSummary sampleStats2, 
           double alpha)
           throws IllegalArgumentException, MathException;
       
  @@ -495,12 +495,12 @@
        * </li></ul>
        *
        * @param mu constant value to compare sample mean against
  -     * @param sampleStats DescriptiveStatistics describing sample data values
  +     * @param sampleStats StatisticalSummary describing sample data values
        * @param alpha significance level of the test
        * @return p-value
        * @throws IllegalArgumentException if the precondition is not met
        */
  -    boolean tTest(double mu, DescriptiveStatistics sampleStats, double alpha)
  +    boolean tTest(double mu, StatisticalSummary sampleStats, double alpha)
           throws IllegalArgumentException, MathException;
       
       /**
  @@ -526,11 +526,11 @@
        * </li></ul>
        *
        * @param mu constant value to compare sample mean against
  -     * @param sampleStats DescriptiveStatistics describing sample data
  +     * @param sampleStats StatisticalSummary describing sample data
        * @return p-value
        * @throws IllegalArgumentException if the precondition is not met
        */
  -    double tTest(double mu, DescriptiveStatistics sampleStats)
  +    double tTest(double mu, StatisticalSummary sampleStats)
           throws IllegalArgumentException, MathException;
   }
   
  
  
  
  1.11      +20 -20    jakarta-commons/math/src/java/org/apache/commons/math/stat/TestStatisticImpl.java
  
  Index: TestStatisticImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/stat/TestStatisticImpl.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- TestStatisticImpl.java	19 Nov 2003 03:22:54 -0000	1.10
  +++ TestStatisticImpl.java	25 Jan 2004 21:30:41 -0000	1.11
  @@ -1,7 +1,7 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2003 The Apache Software Foundation.  All rights
  + * Copyright (c) 2003-2004 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -255,11 +255,11 @@
   
       /**
        * @param mu comparison constant
  -     * @param sampleStats DescriptiveStatistics holding sample summary statitstics
  +     * @param sampleStats StatisticalSummary holding sample summary statitstics
        * @return t statistic
        * @throws IllegalArgumentException if the precondition is not met
        */
  -    public double t(double mu, DescriptiveStatistics sampleStats)
  +    public double t(double mu, StatisticalSummary sampleStats)
           throws IllegalArgumentException {
           if ((sampleStats == null) || (sampleStats.getN() < 5)) {
               throw new IllegalArgumentException("insufficient data for t statistic");
  @@ -272,14 +272,14 @@
       }
   
       /**
  -     * @param sampleStats1 DescriptiveStatistics describing data from the first sample
  -     * @param sampleStats2 DescriptiveStatistics describing data from the second sample
  +     * @param sampleStats1 StatisticalSummary describing data from the first sample
  +     * @param sampleStats2 StatisticalSummary describing data from the second sample
        * @return t statistic
        * @throws IllegalArgumentException if the precondition is not met
        */
       public double t(
  -        DescriptiveStatistics sampleStats1,
  -        DescriptiveStatistics sampleStats2)
  +        StatisticalSummary sampleStats1,
  +        StatisticalSummary sampleStats2)
           throws IllegalArgumentException {
           if ((sampleStats1 == null)
               || (sampleStats2 == null
  @@ -296,14 +296,14 @@
       }
   
       /**
  -     * @param sampleStats1 DescriptiveStatistics describing data from the first sample
  -     * @param sampleStats2 DescriptiveStatistics describing data from the second sample
  +     * @param sampleStats1 StatisticalSummary describing data from the first sample
  +     * @param sampleStats2 StatisticalSummary describing data from the second sample
        * @return p-value for t-test
        * @throws IllegalArgumentException if the precondition is not met
        */
       public double tTest(
  -        DescriptiveStatistics sampleStats1,
  -        DescriptiveStatistics sampleStats2)
  +        StatisticalSummary sampleStats1,
  +        StatisticalSummary sampleStats2)
           throws IllegalArgumentException, MathException {
           if ((sampleStats1 == null)
               || (sampleStats2 == null
  @@ -320,16 +320,16 @@
       }
   
       /**
  -     * @param sampleStats1 DescriptiveStatistics describing sample data values
  -     * @param sampleStats2 DescriptiveStatistics describing sample data values
  +     * @param sampleStats1 StatisticalSummary describing sample data values
  +     * @param sampleStats2 StatisticalSummary describing sample data values
        * @param alpha significance level of the test
        * @return true if the null hypothesis can be rejected with 
        * confidence 1 - alpha
        * @throws IllegalArgumentException if the preconditions are not met
        */
       public boolean tTest(
  -        DescriptiveStatistics sampleStats1,
  -        DescriptiveStatistics sampleStats2,
  +        StatisticalSummary sampleStats1,
  +        StatisticalSummary sampleStats2,
           double alpha)
           throws IllegalArgumentException, MathException {
           if ((alpha <= 0) || (alpha > 0.5)) {
  @@ -341,14 +341,14 @@
   
       /**
        * @param mu constant value to compare sample mean against
  -     * @param sampleStats DescriptiveStatistics describing sample data values
  +     * @param sampleStats StatisticalSummary describing sample data values
        * @param alpha significance level of the test
        * @return p-value
        * @throws IllegalArgumentException if the precondition is not met
        */
       public boolean tTest(
           double mu,
  -        DescriptiveStatistics sampleStats,
  +        StatisticalSummary sampleStats,
           double alpha)
           throws IllegalArgumentException, MathException {
           if ((alpha <= 0) || (alpha > 0.5)) {
  @@ -360,11 +360,11 @@
   
       /**
        * @param mu constant value to compare sample mean against
  -     * @param sampleStats DescriptiveStatistics describing sample data
  +     * @param sampleStats StatisticalSummary describing sample data
        * @return p-value
        * @throws IllegalArgumentException if the precondition is not met
        */
  -    public double tTest(double mu, DescriptiveStatistics sampleStats)
  +    public double tTest(double mu, StatisticalSummary sampleStats)
           throws IllegalArgumentException, MathException {
           if ((sampleStats == null) || (sampleStats.getN() < 5)) {
               throw new IllegalArgumentException("insufficient data for t statistic");
  
  
  
  1.1                  jakarta-commons/math/src/java/org/apache/commons/math/stat/StatisticalSummary.java
  
  Index: StatisticalSummary.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2004 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their name without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.commons.math.stat;
  
  /**
   *  Reporting interface for basic univariate statistics.
   * 
    * @version $Revision: 1.1 $ $Date: 2004/01/25 21:30:41 $
   */
  public interface StatisticalSummary {
  	/** 
  	 * Returns the <a href="http://www.xycoon.com/arithmetic_mean.htm">
  	 * arithmetic mean </a> of the available values 
  	 * @return The mean or Double.NaN if no values have been added.
  	 */
  	public abstract double getMean();
  	/** 
  	 * Returns the variance of the available values.
  	 * @return The variance, Double.NaN if no values have been added 
  	 * or 0.0 for a single value set.  
  	 */
  	public abstract double getVariance();
  	/** 
  	 * Returns the standard deviation of the available values.
  	 * @return The standard deviation, Double.NaN if no values have been added 
  	 * or 0.0 for a single value set. 
  	 */
  	public abstract double getStandardDeviation();
  	/** 
  	 * Returns the maximum of the available values
  	 * @return The max or Double.NaN if no values have been added.
  	 */
  	public abstract double getMax();
  	/** 
  	* Returns the minimum of the available values
  	* @return The min or Double.NaN if no values have been added.
  	*/
  	public abstract double getMin();
  	/** 
  	 * Returns the number of available values
  	 * @return The number of available values
  	 */
  	public abstract long getN();
  	/**
  	 * Returns the sum of the values that have been added to Univariate.
  	 * @return The sum or Double.NaN if no values have been added
  	 */
  	public abstract double getSum();
  }
  
  
  1.1                  jakarta-commons/math/src/java/org/apache/commons/math/stat/SummaryStatistics.java
  
  Index: SummaryStatistics.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2004 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their name without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.commons.math.stat;
  
  import java.io.Serializable;
  
  import org.apache.commons.discovery.tools.DiscoverClass;
  
  /**
   * Abstract factory class for univariate statistical summaries.
   * 
   * @version $Revision: 1.1 $ $Date: 2004/01/25 21:30:41 $
   */
  public abstract class SummaryStatistics implements Serializable, StatisticalSummary{
  
  	/**
  	 * Create an instance of a <code>SummaryStatistics</code>
  	 * @return a new factory. 
  	 */
  	public static SummaryStatistics newInstance(String cls) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
  		return newInstance(Class.forName(cls));
  	}
  	/**
  	 * Create an instance of a <code>DescriptiveStatistics</code>
  	 * @return a new factory. 
  	 */
  	public static SummaryStatistics newInstance(Class cls) throws InstantiationException, IllegalAccessException {
  		return (SummaryStatistics)cls.newInstance();
  	}
  	
  		/**
  	 * Create an instance of a <code>DescriptiveStatistics</code>
  	 * @return a new factory. 
  	 */
  	public static SummaryStatistics newInstance() {
  		SummaryStatistics factory = null;
  		try {
  			DiscoverClass dc = new DiscoverClass();
  			factory = (SummaryStatistics) dc.newInstance(
  				SummaryStatistics.class,
  				"org.apache.commons.math.stat.SummaryStatisticsImpl");
  		} catch(Exception ex) {
  			// ignore as default implementation will be used.
  		}
  		return factory;
  	}
  	
  	/**
  	 * Adds the value to the data to be summarized
  	 * @param v the value to be added 
  	 */
  	public abstract void addValue(double v);
  
  	/** 
  	 * Returns the <a href="http://www.xycoon.com/arithmetic_mean.htm">
  	 * arithmetic mean </a> of the available values 
  	 * @return The mean or Double.NaN if no values have been added.
  	 */
  	public abstract double getMean();
  
  	/** 
  	 * Returns the <a href="http://www.xycoon.com/geometric_mean.htm">
  	 * geometric mean </a> of the available values
  	 * @return The geometricMean, Double.NaN if no values have been added, 
  	 * or if the productof the available values is less than or equal to 0.
  	 */
  	public abstract double getGeometricMean();
  
  	/** 
  	 * Returns the variance of the available values.
  	 * @return The variance, Double.NaN if no values have been added 
  	 * or 0.0 for a single value set.  
  	 */
  	public abstract double getVariance();
  
  	/** 
  	 * Returns the standard deviation of the available values.
  	 * @return The standard deviation, Double.NaN if no values have been added 
  	 * or 0.0 for a single value set. 
  	 */
  	public abstract double getStandardDeviation();
      
  	/** 
  	 * Returns the maximum of the available values
  	 * @return The max or Double.NaN if no values have been added.
  	 */
  	public abstract double getMax();
  
  	/** 
  	* Returns the minimum of the available values
  	* @return The min or Double.NaN if no values have been added.
  	*/
  	public abstract double getMin();
  
  	/** 
  	 * Returns the number of available values
  	 * @return The number of available values
  	 */
  	public abstract long getN();
  
  	/**
  	 * Returns the sum of the values that have been added to Univariate.
  	 * @return The sum or Double.NaN if no values have been added
  	 */
  	public abstract double getSum();
  
  	/**
  	 * Returns the sum of the squares of the available values.
  	 * @return The sum of the squares or Double.NaN if no 
  	 * values have been added.
  	 */
  	public abstract double getSumsq();
  
  	/** 
  	 * Resets all statistics
  	 */
  	public abstract void clear();
  
  }
  
  
  
  1.1                  jakarta-commons/math/src/java/org/apache/commons/math/stat/SummaryStatisticsImpl.java
  
  Index: SummaryStatisticsImpl.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2004 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their name without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.commons.math.stat;
  
  import org.apache.commons.math.stat.univariate.moment.SecondMoment;
  import org.apache.commons.math.stat.univariate.moment.FirstMoment;
  import org.apache.commons.math.stat.univariate.moment.GeometricMean;
  import org.apache.commons.math.stat.univariate.moment.Mean;
  import org.apache.commons.math.stat.univariate.moment.Variance;
  import org.apache.commons.math.stat.univariate.rank.Max;
  import org.apache.commons.math.stat.univariate.rank.Min;
  import org.apache.commons.math.stat.univariate.summary.Sum;
  import org.apache.commons.math.stat.univariate.summary.SumOfLogs;
  import org.apache.commons.math.stat.univariate.summary.SumOfSquares;
  
  /**
   * Provides a default {@link SummaryStatistics} implementation.
   * 
   * @version $Revision: 1.1 $ $Date: 2004/01/25 21:30:41 $  
   */
  public class SummaryStatisticsImpl extends SummaryStatistics {
  
      /** count of values that have been added */
      protected long n = 0;
  
      /** FirstMoment is used to compute the mean */
      protected FirstMoment firstMoment = null;
      
      /** SecondMoment is used to compute the variance */
      protected SecondMoment secondMoment = null;
      
      /** sum of values that have been added */
      protected Sum sum = null;
  
      /** sum of the square of each value that has been added */
      protected SumOfSquares sumsq = null;
  
      /** min of values that have been added */
      protected Min min = null;
  
      /** max of values that have been added */
      protected Max max = null;
  
      /** sumLog of values that have been added */
      protected SumOfLogs sumLog = null;
  
      /** geoMean of values that have been added */
      protected GeometricMean geoMean = null;
  
      /** mean of values that have been added */
      protected Mean mean = null;
  
      /** variance of values that have been added */
      protected Variance variance = null;
  
      /**
       * Construct a SummaryStatistics
       */
      public SummaryStatisticsImpl() {
          sum = new Sum();
          sumsq = new SumOfSquares();
          min = new Min();
          max = new Max();
          sumLog = new SumOfLogs();
          geoMean = new GeometricMean();
          secondMoment = new SecondMoment();
          firstMoment = new FirstMoment();
      }
  
      /**
       * Add a value to the data
       * 
       * @param value  the value to add
       */
      public void addValue(double value) {
      	sum.increment(value);
      	sumsq.increment(value);
      	min.increment(value);
      	max.increment(value);
      	sumLog.increment(value);
      	geoMean.increment(value);
      	firstMoment.increment(value);
      	secondMoment.increment(value);
      	n++;
      }
  
      /**
       * @see org.apache.commons.math.stat.Univariate#getN()
       */
      public long getN() {
          return n;
      }
  
      /**
       * @see org.apache.commons.math.stat.Univariate#getSum()
       */
      public double getSum() {
          return sum.getResult();
      }
  
      /**
       * Returns the sum of the squares of the values that have been added.
       * <p>
       *  Double.NaN is returned if no values have been added.</p>
       * 
       * @return The sum of squares
       */
      public double getSumsq() {
          return sumsq.getResult();
      }
  
      /**
       * Returns the mean of the values that have been added.
       * <p>
       *  Double.NaN is returned if no values have been added.</p>
       * 
       * @return the mean
       */
      public double getMean() {
        return new Mean(firstMoment).getResult();
      }
  
      /**
       * Returns the standard deviation of the values that have been added.
       * <p>
       *  Double.NaN is returned if no values have been added.</p>
       * 
       * @return the standard deviation
       */
      public double getStandardDeviation() {
          double stdDev = Double.NaN;
          if (getN() > 0) {
              if (getN() > 1) {
                  stdDev = Math.sqrt(getVariance());
              } else {
                  stdDev = 0.0;
              }
          }
          return (stdDev);
      }
  
      /**
       * Returns the variance of the values that have been added.
       * <p>
       *  Double.NaN is returned if no values have been added.</p>
       *
       * @return the variance 
       */
      public double getVariance() {
          return new Variance(secondMoment).getResult();
      }
  
      /**
       * Returns the maximum of the values that have been added.
       * <p>
       *  Double.NaN is returned if no values have been added.</p>
       *
       * @return the maximum  
       */
      public double getMax() {
          return max.getResult();
      }
  
      /**
       * Returns the minimum of the values that have been added.
       * <p>
       *  Double.NaN is returned if no values have been added.</p>
       *
       * @return the minimum  
       */
      public double getMin() {
          return min.getResult();
      }
  
      /**
       * Returns the geometric mean of the values that have been added.
       * <p>
       *  Double.NaN is returned if no values have been added.</p>
       *
       * @return the geometric mean  
       */
      public double getGeometricMean() {
          return geoMean.getResult();
      }
      
      /**
       * Generates a text report displaying
       * summary statistics from values that
       * have been added.
       * @return String with line feeds displaying statistics
       */
      public String toString() {
          StringBuffer outBuffer = new StringBuffer();
          outBuffer.append("SummaryStatistics:\n");
          outBuffer.append("n: " + n + "\n");
          outBuffer.append("min: " + min + "\n");
          outBuffer.append("max: " + max + "\n");
          outBuffer.append("mean: " + getMean() + "\n");
          outBuffer.append("std dev: " + getStandardDeviation() + "\n");
          return outBuffer.toString();
      }
  
      /** 
  	 * Resets all statistics and storage
  	 */
      public void clear() {
          this.n = 0;
          min.clear();
          max.clear();
          sum.clear();
          sumLog.clear();
          sumsq.clear();
          geoMean.clear();
          firstMoment.clear();
          secondMoment.clear();
      }
  
  }
  
  
  1.12      +4 -4      jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/moment/FirstMoment.java
  
  Index: FirstMoment.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/moment/FirstMoment.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- FirstMoment.java	19 Nov 2003 03:28:24 -0000	1.11
  +++ FirstMoment.java	25 Jan 2004 21:30:41 -0000	1.12
  @@ -1,7 +1,7 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2003 The Apache Software Foundation.  All rights
  + * Copyright (c) 2003-2004 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -68,10 +68,10 @@
    */
   public class FirstMoment extends AbstractStorelessUnivariateStatistic implements Serializable{
   
  -    static final long serialVersionUID = -803343206421984070L;    
  +    static final long serialVersionUID = -803343206421984070L; 
       
       /** count of values that have been added */
  -    protected int n = 0;
  +    protected long n = 0;
   
       /** first moment of values that have been added */
       protected double m1 = Double.NaN;
  
  
  
  1.15      +3 -3      jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/moment/GeometricMean.java
  
  Index: GeometricMean.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/moment/GeometricMean.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- GeometricMean.java	19 Nov 2003 03:28:24 -0000	1.14
  +++ GeometricMean.java	25 Jan 2004 21:30:41 -0000	1.15
  @@ -1,7 +1,7 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2003 The Apache Software Foundation.  All rights
  + * Copyright (c) 2003-2004 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -67,7 +67,7 @@
       static final long serialVersionUID = -8178734905303459453L;  
         
       /** */
  -    protected int n = 0;
  +    protected long n = 0;
   
       /** */
       private double geoMean = Double.NaN;
  
  
  
  1.15      +3 -3      jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/moment/Kurtosis.java
  
  Index: Kurtosis.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/moment/Kurtosis.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Kurtosis.java	19 Nov 2003 03:28:24 -0000	1.14
  +++ Kurtosis.java	25 Jan 2004 21:30:41 -0000	1.15
  @@ -1,7 +1,7 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2003 The Apache Software Foundation.  All rights
  + * Copyright (c) 2003-2004 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -80,7 +80,7 @@
       private double kurtosis = Double.NaN;
   
       /** */
  -    private int n = 0;
  +    private long n = 0;
   
       /**
        * Construct a Kurtosis
  
  
  
  1.15      +3 -3      jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/moment/Skewness.java
  
  Index: Skewness.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/moment/Skewness.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Skewness.java	19 Nov 2003 03:28:24 -0000	1.14
  +++ Skewness.java	25 Jan 2004 21:30:41 -0000	1.15
  @@ -1,7 +1,7 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2003 The Apache Software Foundation.  All rights
  + * Copyright (c) 2003-2004 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -74,7 +74,7 @@
       protected double skewness = Double.NaN;
   
       /** */
  -    private int n = 0;
  +    private long n = 0;
   
       /**
        * Constructs a Skewness
  
  
  
  1.15      +7 -3      jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/moment/Variance.java
  
  Index: Variance.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/moment/Variance.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Variance.java	19 Nov 2003 03:28:24 -0000	1.14
  +++ Variance.java	25 Jan 2004 21:30:41 -0000	1.15
  @@ -58,7 +58,11 @@
   import org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatistic;
   
   /**
  - *
  + * Updating forumulas use West's algorithm as described in
  + * <a href="http://doi.acm.org/10.1145/359146.359152">Chan, T. F. and
  + * J. G. Lewis 1979, <i>Communications of the ACM</i>,
  + * vol. 22 no. 9, pp. 526-531.</a>.
  + * 
    * @version $Revision$ $Date$
    */
   public class Variance extends AbstractStorelessUnivariateStatistic implements Serializable {
  @@ -87,7 +91,7 @@
        * If the external SecondMoment is used, the this is updated from
        * that moments counter
        */
  -    protected int n = 0;
  +    protected long n = 0;
   
       /**
        * Constructs a Variance.
  
  
  
  1.13      +3 -3      jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/rank/Max.java
  
  Index: Max.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/rank/Max.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Max.java	19 Nov 2003 03:28:24 -0000	1.12
  +++ Max.java	25 Jan 2004 21:30:41 -0000	1.13
  @@ -1,7 +1,7 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2003 The Apache Software Foundation.  All rights
  + * Copyright (c) 2003-2004 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -71,7 +71,7 @@
       static final long serialVersionUID = -5593383832225844641L;    
       
       /** */
  -    private int n = 0;
  +    private long n = 0;
           
       /** */
       private double value = Double.NaN;
  
  
  
  1.13      +3 -3      jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/rank/Min.java
  
  Index: Min.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/rank/Min.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Min.java	19 Nov 2003 03:28:24 -0000	1.12
  +++ Min.java	25 Jan 2004 21:30:41 -0000	1.13
  @@ -1,7 +1,7 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2003 The Apache Software Foundation.  All rights
  + * Copyright (c) 2003-2004 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -71,7 +71,7 @@
       static final long serialVersionUID = -2941995784909003131L;  
         
       /** */
  -    private int n = 0;
  +    private long n = 0;
       
       /** */
       private double value = Double.NaN;
  
  
  
  1.13      +35 -24    jakarta-commons/math/src/test/org/apache/commons/math/stat/CertifiedDataTest.java
  
  Index: CertifiedDataTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/test/org/apache/commons/math/stat/CertifiedDataTest.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- CertifiedDataTest.java	15 Nov 2003 16:01:40 -0000	1.12
  +++ CertifiedDataTest.java	25 Jan 2004 21:30:41 -0000	1.13
  @@ -61,14 +61,13 @@
   import java.io.FileNotFoundException;
   import java.io.IOException;
   import java.io.InputStreamReader;
  -import org.apache.commons.logging.*;
  +import org.apache.commons.logging.LogFactory;
  +import org.apache.commons.logging.Log;
   /**
    * Test cases for the {@link DescriptiveStatistics} class.
    * @version $Revision$ $Date$
    */
  -public class CertifiedDataTest extends TestCase {
  -
  -	protected DescriptiveStatistics u = null;
  +public class CertifiedDataTest extends TestCase  {
   
   	protected double mean = Double.NaN;
   
  @@ -103,9 +102,9 @@
   	 * Test StorelessDescriptiveStatistics
   	*/
   	public void testUnivariateImpl() {
  -
  +		SummaryStatistics u = null;
   		try {
  -			u = DescriptiveStatistics.newInstance(StorelessDescriptiveStatisticsImpl.class);
  +			u = SummaryStatistics.newInstance(SummaryStatisticsImpl.class);
   		} catch (InstantiationException e) {
   			// TODO Auto-generated catch block
   			e.printStackTrace();
  @@ -114,19 +113,19 @@
   			e.printStackTrace();
   		}
   
  -		loadStats("data/Lew.txt");
  +		loadStats("data/Lew.txt", u);
   		assertEquals("Lew: std", std, u.getStandardDeviation(), .000000000001);
   		assertEquals("Lew: mean", mean, u.getMean(), .000000000001);
   		
  -		loadStats("data/Lottery.txt");
  +		loadStats("data/Lottery.txt", u);
   		assertEquals("Lottery: std", std, u.getStandardDeviation(), .000000000001);
   		assertEquals("Lottery: mean", mean, u.getMean(), .000000000001);	
   		
  -		loadStats("data/PiDigits.txt");
  +		loadStats("data/PiDigits.txt", u);
   		assertEquals("PiDigits: std", std, u.getStandardDeviation(), .0000000000001);
   		assertEquals("PiDigits: mean", mean, u.getMean(), .0000000000001);	
   
  -		loadStats("data/Mavro.txt");
  +		loadStats("data/Mavro.txt", u);
   		assertEquals("Mavro: std", std, u.getStandardDeviation(), .00000000000001);
   		assertEquals("Mavro: mean", mean, u.getMean(), .00000000000001);
   		
  @@ -134,7 +133,7 @@
   		//assertEquals("Michelso: std", std, u.getStandardDeviation(), .00000000000001);
   		//assertEquals("Michelso: mean", mean, u.getMean(), .00000000000001);	
   										
  -		loadStats("data/NumAcc1.txt");
  +		loadStats("data/NumAcc1.txt", u);
   		assertEquals("NumAcc1: std", std, u.getStandardDeviation(), .00000000000001);
   		assertEquals("NumAcc1: mean", mean, u.getMean(), .00000000000001);
   		
  @@ -148,21 +147,21 @@
   	 */
   	public void testStoredUnivariateImpl() {
   
  -		u = DescriptiveStatistics.newInstance();
  +		DescriptiveStatistics u = DescriptiveStatistics.newInstance();
   		
  -		loadStats("data/Lew.txt");
  +		loadStats("data/Lew.txt", u);
   		assertEquals("Lew: std", std, u.getStandardDeviation(), .000000000001);
   		assertEquals("Lew: mean", mean, u.getMean(), .000000000001);
   		
  -		loadStats("data/Lottery.txt");
  +		loadStats("data/Lottery.txt", u);
   		assertEquals("Lottery: std", std, u.getStandardDeviation(), .000000000001);
   		assertEquals("Lottery: mean", mean, u.getMean(), .000000000001);		
   																  
  -		loadStats("data/PiDigits.txt");
  +		loadStats("data/PiDigits.txt", u);
   		assertEquals("PiDigits: std", std, u.getStandardDeviation(), .0000000000001);
   		assertEquals("PiDigits: mean", mean, u.getMean(), .0000000000001);
   		
  -		loadStats("data/Mavro.txt");
  +		loadStats("data/Mavro.txt", u);
   		assertEquals("Mavro: std", std, u.getStandardDeviation(), .00000000000001);
   		assertEquals("Mavro: mean", mean, u.getMean(), .00000000000001);		
   		
  @@ -170,7 +169,7 @@
   		//assertEquals("Michelso: std", std, u.getStandardDeviation(), .00000000000001);
   		//assertEquals("Michelso: mean", mean, u.getMean(), .00000000000001);	
   
  -		loadStats("data/NumAcc1.txt");
  +		loadStats("data/NumAcc1.txt", u);
   		assertEquals("NumAcc1: std", std, u.getStandardDeviation(), .00000000000001);
   		assertEquals("NumAcc1: mean", mean, u.getMean(), .00000000000001);
   		
  @@ -182,12 +181,19 @@
   	/**
   	 * loads a DescriptiveStatistics off of a test file
   	 * @param file
  +	 * @param statistical summary
   	 */
  -	private void loadStats(String resource) {
  -
  +	private void loadStats(String resource, Object u) {
  +		
  +		DescriptiveStatistics d = null;
  +		SummaryStatistics s = null;
  +		if (u instanceof DescriptiveStatistics) {
  +			d = (DescriptiveStatistics) u;
  +		} else {
  +			s = (SummaryStatistics) u;
  +		}
   		try {
  -
  -			u.clear();
  +			u.getClass().getDeclaredMethod("clear", null).invoke(u, null);
   			mean = Double.NaN;
   			std = Double.NaN;
   
  @@ -215,8 +221,11 @@
   			line = in.readLine();
   
   			while (line != null) {
  -
  -				u.addValue(Double.parseDouble(line.trim()));
  +				if (d != null) {
  +					d.addValue(Double.parseDouble(line.trim()));
  +				}  else {
  +					s.addValue(Double.parseDouble(line.trim()));
  +				}
   				line = in.readLine();
   			}
   
  @@ -225,6 +234,8 @@
   		} catch (FileNotFoundException fnfe) {
   			log.error(fnfe.getMessage(), fnfe);
   		} catch (IOException ioe) {
  +			log.error(ioe.getMessage(), ioe);
  +		} catch (Exception ioe) {
   			log.error(ioe.getMessage(), ioe);
   		}
   	}
  
  
  
  1.2       +23 -4     jakarta-commons/math/src/test/org/apache/commons/math/stat/ListUnivariateImpl.java
  
  Index: ListUnivariateImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/test/org/apache/commons/math/stat/ListUnivariateImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ListUnivariateImpl.java	15 Nov 2003 16:01:41 -0000	1.1
  +++ ListUnivariateImpl.java	25 Jan 2004 21:30:41 -0000	1.2
  @@ -1,7 +1,7 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2003 The Apache Software Foundation.  All rights
  + * Copyright (c) 2003-2004 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -73,6 +73,9 @@
   
       /** Number Transformer maps Objects to Number for us. */
       protected NumberTransformer transformer;
  +    
  +    /** hold the window size **/
  +    protected int windowSize = DescriptiveStatistics.INFINITE_WINDOW;
   
       /**
        * Construct a ListUnivariate with a specific List.
  @@ -149,7 +152,7 @@
       /**
        * @see org.apache.commons.math.stat.DescriptiveStatistics#getN()
        */
  -    public int getN() {
  +    public long getN() {
           int n = 0;
   
           if (windowSize != DescriptiveStatistics.INFINITE_WINDOW) {
  @@ -183,7 +186,6 @@
        * @see org.apache.commons.math.stat.DescriptiveStatistics#clear()
        */
       public void clear() {
  -        super.clear();
           list.clear();
       }
       
  @@ -216,5 +218,22 @@
       public void setTransformer(NumberTransformer transformer) {
           this.transformer = transformer;
       }
  +    
  +    /**
  +     * @see org.apache.commons.math.stat.Univariate#setWindowSize(int)
  +     */
  +    public synchronized void setWindowSize(int windowSize) {
  +    	this.windowSize = windowSize;
  +    	//Discard elements from the front of the list if the windowSize is less than 
  +    	// the size of the list.
  +    	int extra = list.size() - windowSize;
  +    	for (int i = 0; i < extra; i++) {
  +    		list.remove(0);
  +    	}
  +    }
  +    	
  +    	public int getWindowSize() {
  +    		return windowSize;
  +    	}
   
   }
  
  
  
  1.11      +2 -2      jakarta-commons/math/src/test/org/apache/commons/math/stat/ListUnivariateImplTest.java
  
  Index: ListUnivariateImplTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/test/org/apache/commons/math/stat/ListUnivariateImplTest.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ListUnivariateImplTest.java	15 Nov 2003 16:01:41 -0000	1.10
  +++ ListUnivariateImplTest.java	25 Jan 2004 21:30:41 -0000	1.11
  @@ -1,7 +1,7 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2003 The Apache Software Foundation.  All rights
  + * Copyright (c) 2003-2004 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  
  
  
  1.11      +2 -2      jakarta-commons/math/src/test/org/apache/commons/math/stat/StoreUnivariateImplTest.java
  
  Index: StoreUnivariateImplTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/test/org/apache/commons/math/stat/StoreUnivariateImplTest.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- StoreUnivariateImplTest.java	15 Nov 2003 16:01:41 -0000	1.10
  +++ StoreUnivariateImplTest.java	25 Jan 2004 21:30:41 -0000	1.11
  @@ -1,7 +1,7 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2003 The Apache Software Foundation.  All rights
  + * Copyright (c) 2003-2004 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  
  
  
  1.10      +17 -77    jakarta-commons/math/src/test/org/apache/commons/math/stat/TestStatisticTest.java
  
  Index: TestStatisticTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/test/org/apache/commons/math/stat/TestStatisticTest.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- TestStatisticTest.java	19 Nov 2003 03:22:54 -0000	1.9
  +++ TestStatisticTest.java	25 Jan 2004 21:30:41 -0000	1.10
  @@ -1,7 +1,7 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2003 The Apache Software Foundation.  All rights
  + * Copyright (c) 2003-2004 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -186,11 +186,11 @@
                   92.0,
                   95.0 };
           double mu = 100.0;
  -        DescriptiveStatistics sampleStats = null;
  +        SummaryStatistics sampleStats = null;
           try {
               sampleStats =
  -                DescriptiveStatistics.newInstance(
  -                    StorelessDescriptiveStatisticsImpl.class);
  +                SummaryStatistics.newInstance(
  +                    SummaryStatisticsImpl.class);
           } catch (InstantiationException e5) {
               // TODO Auto-generated catch block
               e5.printStackTrace();
  @@ -221,18 +221,8 @@
               ;
           }
   
  -        DescriptiveStatistics nullStats = null;
  -        try {
  -            nullStats =
  -                DescriptiveStatistics.newInstance(
  -                    StorelessDescriptiveStatisticsImpl.class);
  -        } catch (InstantiationException e6) {
  -            // TODO Auto-generated catch block
  -            e6.printStackTrace();
  -        } catch (IllegalAccessException e6) {
  -            // TODO Auto-generated catch block
  -            e6.printStackTrace();
  -        }
  +        SummaryStatistics nullStats = SummaryStatistics.newInstance();
  +         
           try {
               testStatistic.t(mu, nullStats);
               fail("arguments too short, IllegalArgumentException expected");
  @@ -249,18 +239,8 @@
               ;
           }
   
  -        DescriptiveStatistics emptyStats = null;
  -        try {
  -            emptyStats =
  -                DescriptiveStatistics.newInstance(
  -                    StorelessDescriptiveStatisticsImpl.class);
  -        } catch (InstantiationException e4) {
  -            // TODO Auto-generated catch block
  -            e4.printStackTrace();
  -        } catch (IllegalAccessException e4) {
  -            // TODO Auto-generated catch block
  -            e4.printStackTrace();
  -        }
  +        SummaryStatistics emptyStats =SummaryStatistics.newInstance();
  +        
           try {
               testStatistic.t(mu, emptyStats);
               fail("arguments too short, IllegalArgumentException expected");
  @@ -285,18 +265,8 @@
               e.printStackTrace();
           }
   
  -        DescriptiveStatistics tooShortStats = null;
  -        try {
  -            tooShortStats =
  -                DescriptiveStatistics.newInstance(
  -                    StorelessDescriptiveStatisticsImpl.class);
  -        } catch (InstantiationException e3) {
  -            // TODO Auto-generated catch block
  -            e3.printStackTrace();
  -        } catch (IllegalAccessException e3) {
  -            // TODO Auto-generated catch block
  -            e3.printStackTrace();
  -        }
  +        SummaryStatistics tooShortStats = SummaryStatistics.newInstance();
  +        
           tooShortStats.addValue(0d);
           tooShortStats.addValue(2d);
           try {
  @@ -339,18 +309,8 @@
                   3d,
                   3d };
   
  -        DescriptiveStatistics oneSidedPStats = null;
  -        try {
  -            oneSidedPStats =
  -                DescriptiveStatistics.newInstance(
  -                    StorelessDescriptiveStatisticsImpl.class);
  -        } catch (InstantiationException e2) {
  -            // TODO Auto-generated catch block
  -            e2.printStackTrace();
  -        } catch (IllegalAccessException e2) {
  -            // TODO Auto-generated catch block
  -            e2.printStackTrace();
  -        }
  +        SummaryStatistics oneSidedPStats = SummaryStatistics.newInstance();;
  +        
           for (int i = 0; i < oneSidedP.length; i++) {
               oneSidedPStats.addValue(oneSidedP[i]);
           }
  @@ -418,34 +378,14 @@
           double[] sample2 =
               { -1d, 12d, -1d, -3d, 3d, -5d, 5d, 2d, -11d, -1d, -3d };
   
  -        DescriptiveStatistics sampleStats1 = null;
  -        try {
  -            sampleStats1 =
  -                DescriptiveStatistics.newInstance(
  -                    StorelessDescriptiveStatisticsImpl.class);
  -        } catch (InstantiationException e1) {
  -            // TODO Auto-generated catch block
  -            e1.printStackTrace();
  -        } catch (IllegalAccessException e1) {
  -            // TODO Auto-generated catch block
  -            e1.printStackTrace();
  -        }
  +        SummaryStatistics sampleStats1 = SummaryStatistics.newInstance();
  +        
           for (int i = 0; i < sample1.length; i++) {
               sampleStats1.addValue(sample1[i]);
           }
   
  -        DescriptiveStatistics sampleStats2 = null;
  -        try {
  -            sampleStats2 =
  -                DescriptiveStatistics.newInstance(
  -                    StorelessDescriptiveStatisticsImpl.class);
  -        } catch (InstantiationException e) {
  -            // TODO Auto-generated catch block
  -            e.printStackTrace();
  -        } catch (IllegalAccessException e) {
  -            // TODO Auto-generated catch block
  -            e.printStackTrace();
  -        }
  +        SummaryStatistics sampleStats2 = SummaryStatistics.newInstance();
  +        
           for (int i = 0; i < sample2.length; i++) {
               sampleStats2.addValue(sample2[i]);
           }
  
  
  
  1.10      +2 -2      jakarta-commons/math/src/test/org/apache/commons/math/stat/univariate/StorelessUnivariateStatisticAbstractTest.java
  
  Index: StorelessUnivariateStatisticAbstractTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/test/org/apache/commons/math/stat/univariate/StorelessUnivariateStatisticAbstractTest.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- StorelessUnivariateStatisticAbstractTest.java	19 Nov 2003 13:35:10 -0000	1.9
  +++ StorelessUnivariateStatisticAbstractTest.java	25 Jan 2004 21:30:41 -0000	1.10
  @@ -1,7 +1,7 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2003 The Apache Software Foundation.  All rights
  + * Copyright (c) 2003-2004 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  
  
  
  1.2       +7 -72     jakarta-commons/math/src/test/org/apache/commons/math/stat/univariate/UnivariateImplTest.java
  
  Index: UnivariateImplTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/test/org/apache/commons/math/stat/univariate/UnivariateImplTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- UnivariateImplTest.java	15 Nov 2003 16:01:41 -0000	1.1
  +++ UnivariateImplTest.java	25 Jan 2004 21:30:41 -0000	1.2
  @@ -1,7 +1,7 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2003 The Apache Software Foundation.  All rights
  + * Copyright (c) 2003-2004 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -53,8 +53,7 @@
    */
   package org.apache.commons.math.stat.univariate;
   
  -import org.apache.commons.math.stat.DescriptiveStatistics;
  -import org.apache.commons.math.stat.StorelessDescriptiveStatisticsImpl;
  +import org.apache.commons.math.stat.SummaryStatistics;
   
   import junit.framework.Test;
   import junit.framework.TestCase;
  @@ -96,7 +95,7 @@
       
       /** test stats */
       public void testStats() {
  -        StorelessDescriptiveStatisticsImpl u = new StorelessDescriptiveStatisticsImpl(); 
  +        SummaryStatistics u = SummaryStatistics.newInstance();
           assertEquals("total count",0,u.getN(),tolerance);
           u.addValue(one);
           u.addValue(twoF);
  @@ -115,19 +114,14 @@
       }     
       
       public void testN0andN1Conditions() throws Exception {
  -    	StorelessDescriptiveStatisticsImpl u = new StorelessDescriptiveStatisticsImpl();
  +    	SummaryStatistics u = SummaryStatistics.newInstance();
           assertTrue("Mean of n = 0 set should be NaN", 
               Double.isNaN( u.getMean() ) );
   		assertTrue("Standard Deviation of n = 0 set should be NaN", 
               Double.isNaN( u.getStandardDeviation() ) );
   		assertTrue("Variance of n = 0 set should be NaN", 
               Double.isNaN(u.getVariance() ) );
  -		assertTrue("skew of n = 0 set should be NaN",
  -			Double.isNaN(u.getSkewness() ) );	
  -		assertTrue("kurtosis of n = 0 set should be NaN", 
  -			Double.isNaN(u.getKurtosis() ) );		
   		
  -	
   		/* n=1 */
   		u.addValue(one);
   		assertTrue("mean should be one (n = 1)", 
  @@ -138,10 +132,6 @@
   			u.getStandardDeviation() == 0.0);
   		assertTrue("variance should be zero (n = 1)", 
   			u.getVariance() == 0.0);
  -		assertTrue("skew should be zero (n = 1)", 
  -			u.getSkewness() == 0.0);
  -		assertTrue("kurtosis should be zero (n = 1)", 
  -			u.getKurtosis() == 0.0);		
   					
   		/* n=2 */				
   		u.addValue(twoF);
  @@ -149,27 +139,11 @@
   			u.getStandardDeviation() != 0.0);
   		assertTrue("variance should not be zero (n = 2)", 
   			u.getVariance() != 0.0);
  -		assertTrue("skew should not be zero (n = 2)", 
  -			u.getSkewness() == 0.0);
  -		assertTrue("kurtosis should be zero (n = 2)", 
  -			u.getKurtosis() == 0.0);
  -
  -		/* n=3 */
  -		u.addValue(twoL);
  -		assertTrue("skew should not be zero (n = 3)", 
  -			u.getSkewness() != 0.0);
  -		assertTrue("kurtosis should be zero (n = 3)", 
  -			u.getKurtosis() == 0.0);
  -        
  -		/* n=4 */
  -		u.addValue(three);
  -		assertTrue("kurtosis should not be zero (n = 4)", 
  -			u.getKurtosis() != 0.0);        
               
       }
   
       public void testProductAndGeometricMean() throws Exception {
  -    	StorelessDescriptiveStatisticsImpl u = new StorelessDescriptiveStatisticsImpl(10);
  +    	SummaryStatistics u = SummaryStatistics.newInstance();
       	    	
           u.addValue( 1.0 );
           u.addValue( 2.0 );
  @@ -178,33 +152,10 @@
   
           assertEquals( "Geometric mean not expected", 2.213364, 
               u.getGeometricMean(), 0.00001 );
  -
  -        // Now test rolling - StorelessDescriptiveStatistics should discount the contribution
  -        // of a discarded element
  -        for( int i = 0; i < 10; i++ ) {
  -            u.addValue( i + 2 );
  -        }
  -        // Values should be (2,3,4,5,6,7,8,9,10,11)
  -        
  -        assertEquals( "Geometric mean not expected", 5.755931, 
  -            u.getGeometricMean(), 0.00001 );
  -    }
  -    
  -    public void testRollingMinMax() {
  -        StorelessDescriptiveStatisticsImpl u = new StorelessDescriptiveStatisticsImpl(3);
  -        u.addValue( 1.0 );
  -        u.addValue( 5.0 );
  -        u.addValue( 3.0 );
  -        u.addValue( 4.0 ); // discarding min
  -        assertEquals( "min not expected", 3.0, 
  -            u.getMin(), Double.MIN_VALUE);
  -        u.addValue(1.0);  // discarding max
  -        assertEquals( "max not expected", 4.0, 
  -            u.getMax(), Double.MIN_VALUE);
       }
       
       public void testNaNContracts() {
  -        StorelessDescriptiveStatisticsImpl u = new StorelessDescriptiveStatisticsImpl();
  +    	SummaryStatistics u = SummaryStatistics.newInstance();
           double nan = Double.NaN;
           assertTrue("mean not NaN",Double.isNaN(u.getMean())); 
           assertTrue("min not NaN",Double.isNaN(u.getMin())); 
  @@ -230,21 +181,5 @@
           assertTrue("geom mean not NaN",Double.isNaN(u.getGeometricMean()));
           
           //FiXME: test all other NaN contract specs
  -    }
  -
  -    public void testSkewAndKurtosis() {
  -        DescriptiveStatistics u = new StorelessDescriptiveStatisticsImpl();
  -        
  -        double[] testArray = 
  -        { 12.5, 12, 11.8, 14.2, 14.9, 14.5, 21, 8.2, 10.3, 11.3, 14.1,
  -          9.9, 12.2, 12, 12.1, 11, 19.8, 11, 10, 8.8, 9, 12.3 };
  -        for( int i = 0; i < testArray.length; i++) {
  -            u.addValue( testArray[i]);
  -        }
  -        
  -        assertEquals("mean", 12.40455, u.getMean(), 0.0001);
  -        assertEquals("variance", 10.00236, u.getVariance(), 0.0001);
  -        assertEquals("skewness", 1.437424, u.getSkewness(), 0.0001);
  -        assertEquals("kurtosis", 2.37719, u.getKurtosis(), 0.0001);
       }
   }
  
  
  
  1.9       +2 -2      jakarta-commons/math/src/test/org/apache/commons/math/stat/univariate/UnivariateStatisticAbstractTest.java
  
  Index: UnivariateStatisticAbstractTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/test/org/apache/commons/math/stat/univariate/UnivariateStatisticAbstractTest.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- UnivariateStatisticAbstractTest.java	14 Nov 2003 22:22:23 -0000	1.8
  +++ UnivariateStatisticAbstractTest.java	25 Jan 2004 21:30:41 -0000	1.9
  @@ -1,7 +1,7 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2003 The Apache Software Foundation.  All rights
  + * Copyright (c) 2003-2004 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  
  
  
  1.13      +3 -3      jakarta-commons/math/src/java/org/apache/commons/math/random/EmpiricalDistribution.java
  
  Index: EmpiricalDistribution.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/random/EmpiricalDistribution.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- EmpiricalDistribution.java	15 Jan 2004 05:22:08 -0000	1.12
  +++ EmpiricalDistribution.java	25 Jan 2004 21:30:41 -0000	1.13
  @@ -59,7 +59,7 @@
   import java.net.URL;
   import java.util.ArrayList;
   
  -import org.apache.commons.math.stat.DescriptiveStatistics;
  +import org.apache.commons.math.stat.SummaryStatistics;
   
   /**
    * Represents an <a href="http://random.mat.sbg.ac.at/~ste/dipl/node11.html">
  @@ -123,7 +123,7 @@
        * @return the sample statistics
        * @throws IllegalStateException if the distribution has not been loaded
        */
  -    DescriptiveStatistics getSampleStats() throws IllegalStateException;
  +    SummaryStatistics getSampleStats() throws IllegalStateException;
       
       /** 
        * Loads a saved distribution from a file.
  
  
  
  1.14      +10 -10    jakarta-commons/math/src/java/org/apache/commons/math/random/EmpiricalDistributionImpl.java
  
  Index: EmpiricalDistributionImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/random/EmpiricalDistributionImpl.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- EmpiricalDistributionImpl.java	15 Jan 2004 05:22:08 -0000	1.13
  +++ EmpiricalDistributionImpl.java	25 Jan 2004 21:30:41 -0000	1.14
  @@ -65,7 +65,7 @@
   import java.net.URL;
   
   import org.apache.commons.math.stat.DescriptiveStatistics;
  -import org.apache.commons.math.stat.StorelessDescriptiveStatisticsImpl;
  +import org.apache.commons.math.stat.SummaryStatistics;
   
   /**
    * Implements <code>EmpiricalDistribution</code> interface.  This implementation
  @@ -101,7 +101,7 @@
       private ArrayList binStats = null;
       
       /** Sample statistics */
  -    DescriptiveStatistics sampleStats = null;
  +    SummaryStatistics sampleStats = null;
       
       /** number of bins */
       private int binCount = 1000;
  @@ -175,7 +175,7 @@
       private void computeStats(BufferedReader in) throws IOException {
           String str = null;
           double val = 0.0;
  -        sampleStats = new StorelessDescriptiveStatisticsImpl();
  +        sampleStats = SummaryStatistics.newInstance();
           while ((str = in.readLine()) != null) {
               val = new Double(str).doubleValue();
               sampleStats.addValue(val);
  @@ -205,7 +205,7 @@
               binStats.clear();
           }
           for (int i = 0; i < binCount; i++) {
  -            DescriptiveStatistics stats = new StorelessDescriptiveStatisticsImpl();
  +            SummaryStatistics stats = SummaryStatistics.newInstance();
               binStats.add(i,stats);
           }
           
  @@ -224,7 +224,7 @@
                   }
                   if (val <= binUpperBounds[i]) {
                       found = true;
  -                    DescriptiveStatistics stats = (DescriptiveStatistics)binStats.get(i);
  +                    SummaryStatistics stats = (SummaryStatistics)binStats.get(i);
                       stats.addValue(val);
                   }
                   i++;
  @@ -236,11 +236,11 @@
           // Assign upperBounds based on bin counts
           upperBounds = new double[binCount];
           upperBounds[0] =
  -        ((double)((DescriptiveStatistics)binStats.get(0)).getN())/
  +        ((double)((SummaryStatistics)binStats.get(0)).getN())/
           (double)sampleStats.getN();
           for (int i = 1; i < binCount-1; i++) {
               upperBounds[i] = upperBounds[i-1] +
  -            ((double)((DescriptiveStatistics)binStats.get(i)).getN())/
  +            ((double)((SummaryStatistics)binStats.get(i)).getN())/
               (double)sampleStats.getN();
           }
           upperBounds[binCount-1] = 1.0d;
  @@ -263,7 +263,7 @@
           // Use this to select the bin and generate a Gaussian within the bin
           for (int i = 0; i < binCount; i++) {
              if (x <= upperBounds[i]) {
  -               DescriptiveStatistics stats = (DescriptiveStatistics)binStats.get(i);
  +               SummaryStatistics stats = (SummaryStatistics)binStats.get(i);
                  if (stats.getN() > 0) { 
                      if (stats.getStandardDeviation() > 0) {  // more than one obs 
                           return randomData.nextGaussian
  @@ -295,7 +295,7 @@
          throw new UnsupportedOperationException("Not Implemented yet :-(");
       }
           
  -    public DescriptiveStatistics getSampleStats() {
  +    public SummaryStatistics getSampleStats() {
           return sampleStats;
       }
       
  
  
  
  1.11      +1 -2      jakarta-commons/math/src/java/org/apache/commons/math/random/ValueServer.java
  
  Index: ValueServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/random/ValueServer.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ValueServer.java	15 Jan 2004 05:22:08 -0000	1.10
  +++ ValueServer.java	25 Jan 2004 21:30:41 -0000	1.11
  @@ -240,7 +240,6 @@
        * Sets the <code>valuesFileURL</code> using a string URL representation
        * @param url String representation for new valuesFileURL.
        * @throws MalformedURLException if url is not well formed
  -     * @deprecated use {@link #setValuesFileURL(URL)} to be removed before 0.1 release
        */
       public void setValuesFileURL(String url) throws MalformedURLException {
           this.valuesFileURL = new URL(url);
  
  
  
  1.11      +3 -4      jakarta-commons/math/src/test/org/apache/commons/math/random/EmpiricalDistributionTest.java
  
  Index: EmpiricalDistributionTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/test/org/apache/commons/math/random/EmpiricalDistributionTest.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- EmpiricalDistributionTest.java	15 Jan 2004 05:22:08 -0000	1.10
  +++ EmpiricalDistributionTest.java	25 Jan 2004 21:30:41 -0000	1.11
  @@ -60,8 +60,7 @@
   import java.net.URL;
   import java.net.URLDecoder;
   
  -import org.apache.commons.math.stat.DescriptiveStatistics;
  -import org.apache.commons.math.stat.StorelessDescriptiveStatisticsImpl;
  +import org.apache.commons.math.stat.SummaryStatistics;
   
   /**
    * Test cases for the EmpiricalDistribution class
  @@ -150,7 +149,7 @@
       
       private void tstGen(double tolerance)throws Exception {
           empiricalDistribution.load(file);   
  -        DescriptiveStatistics stats = new StorelessDescriptiveStatisticsImpl();
  +        SummaryStatistics stats = SummaryStatistics.newInstance();
           for (int i = 1; i < 1000; i++) {
               stats.addValue(empiricalDistribution.getNextValue());
           }
  
  
  
  1.9       +3 -4      jakarta-commons/math/src/test/org/apache/commons/math/random/RandomDataTest.java
  
  Index: RandomDataTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/test/org/apache/commons/math/random/RandomDataTest.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- RandomDataTest.java	15 Nov 2003 16:01:40 -0000	1.8
  +++ RandomDataTest.java	25 Jan 2004 21:30:41 -0000	1.9
  @@ -61,9 +61,8 @@
   import java.util.HashSet;
   
   import org.apache.commons.math.stat.Frequency;
  -import org.apache.commons.math.stat.StorelessDescriptiveStatisticsImpl;
  +import org.apache.commons.math.stat.SummaryStatistics;
   import org.apache.commons.math.stat.TestStatisticImpl;
  -import org.apache.commons.math.stat.DescriptiveStatistics;
   
   /**
    * Test cases for the RandomData class.
  @@ -405,7 +404,7 @@
           } catch (IllegalArgumentException ex) {
               ;
           }
  -        DescriptiveStatistics u = new StorelessDescriptiveStatisticsImpl();
  +        SummaryStatistics u = SummaryStatistics.newInstance();
           for (int i = 0; i<largeSampleSize; i++) {
               u.addValue(randomData.nextGaussian(0,1));
           }
  
  
  
  1.12      +4 -5      jakarta-commons/math/src/test/org/apache/commons/math/random/ValueServerTest.java
  
  Index: ValueServerTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/test/org/apache/commons/math/random/ValueServerTest.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ValueServerTest.java	15 Jan 2004 07:31:44 -0000	1.11
  +++ ValueServerTest.java	25 Jan 2004 21:30:41 -0000	1.12
  @@ -58,8 +58,7 @@
   import junit.framework.TestSuite;
   import java.net.URL;
   
  -import org.apache.commons.math.stat.DescriptiveStatistics;
  -import org.apache.commons.math.stat.StorelessDescriptiveStatisticsImpl;
  +import org.apache.commons.math.stat.SummaryStatistics;
    
   /**
    * Test cases for the ValueServer class.
  @@ -103,7 +102,7 @@
           vs.computeDistribution();
           assertTrue("empirical distribution property", 
               vs.getEmpiricalDistribution() != null);
  -        DescriptiveStatistics stats = new StorelessDescriptiveStatisticsImpl();
  +        SummaryStatistics stats = SummaryStatistics.newInstance();
           for (int i = 1; i < 1000; i++) {
               next = vs.getNext();
               stats.addValue(next);
  @@ -114,7 +113,7 @@
               tolerance);
           
           vs.computeDistribution(500);
  -        stats = new StorelessDescriptiveStatisticsImpl();
  +        stats = SummaryStatistics.newInstance();
           for (int i = 1; i < 1000; i++) {
               next = vs.getNext();
               stats.addValue(next);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message