You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Mark R. Diggory" <md...@latte.harvard.edu> on 2003/07/03 04:37:57 UTC

[math] Examples of alternate Univariate approach

I've been working on this refactored implementation over the last week 
or so. Here is a temporary location for the files:

http://osprey.hmdc.harvard.edu:8080/stat2.tar.gz

Please do look them over and let me know what you think. -Mark


This package involves the following changes:

*1* There are three example classes showing how 
Univariate/StoreUnivariate and StatUtil can be factored into this approach.

*2* Instead of all the implementations of the Univariate interface being 
based on StatUtils or AbstractUnivariate, they are now backed by 
Independent (functor like) Classes that implement a 
"UnivariateStatistic" Interface:

public interface UnivariateStatistic {

     public double evaluate(double[] d);

     public double evaluate(DoubleArray d);

}

*3* In the backing implementations, the Storage/Storageless inheritance 
hierarchy is basically "Inverted", in other words, All 
UnivariateStatistics implement these two storage based methods that work 
on double[] and DoubleArray. The Storageless case in this example 
package is now a "exception to the rule". I really like this idea, 
because while all statistics can be implemented over a storage array, 
only some can be done using a storageless approach. I think the "first" 
Interface in the hierarchy should always be the most general. As such, 
StorelessUnivariateStatistics also implement the following extended 
interface:

public interface StorelessUnivariateStatistic extends UnivariateStatistic {

     public double evaluate(double d);

     public double getValue();

     public void clear();
}

The AbstractStorelessUnivariateStatistic is basically polymorphic and 
implements the UnivariateStatistic interface to use the

public double evaluate(double d);

of the StorelessUnivariateStatistic. This allows all Top level 
implementations to only require implementation of two or three methods 
to get a functioning Statistic.

*4* The statistics are all independently implemented in the following 
package hierarchy

o.a.c.m.stat2
    --> ExampleStaticUtils
    --> ExampleUnivariateImpl
    --> ExampleUsage

o.a.c.m.stat2.univariate
     --> interface UnivariateStatistic
     --> interface StorelessUnivariateStatistic
                extends UnivariateStatistic
     --> AbstractUnivariateStatistic
                implements UnivariateStatistic
     --> AbstractStorelessUnivariateStatistic
                implements StorelessUnivariateStatistic

     --> Sum, SumOfSquares, SumOfLogs, Product (all Storeless)

o.a.c.m.stat2.univariate.moment (all Storeless)
     --> Mean, SecondMoment, ThirdMoment, FourthMoment
     --> Variance, StandardDeviation, Skewness, Kurtosis

o.a.c.m.stat2.univariate.rank
     --> Min, Max (Storeless)
     --> Median, Percentile (Not Storeless)

o.a.c.m.util2
     --> Modified versions of DoubleArray, FixedDoubleArray
     --> AbstractDoubleArray,
     --> DoubleArrayIterator, DoubleArrayListIterator



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