By having "UnivariateStatistic" extend the new "MathArrays.Function"
interface, subclassing "ResizableDoubleArray" is not necessary to achieve the required functionality (see MATH-894). git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1410126 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b7555df622
commit
166cfce47f
|
@ -79,7 +79,7 @@ public class DescriptiveStatistics implements StatisticalSummary, Serializable {
|
|||
/**
|
||||
* Stored data values
|
||||
*/
|
||||
private StatArray eDA = new StatArray();
|
||||
private ResizableDoubleArray eDA = new ResizableDoubleArray();
|
||||
|
||||
/** Mean statistic implementation - can be reset by setter. */
|
||||
private UnivariateStatistic meanImpl = new Mean();
|
||||
|
@ -138,7 +138,7 @@ public class DescriptiveStatistics implements StatisticalSummary, Serializable {
|
|||
*/
|
||||
public DescriptiveStatistics(double[] initialDoubleArray) {
|
||||
if (initialDoubleArray != null) {
|
||||
eDA = new StatArray(initialDoubleArray);
|
||||
eDA = new ResizableDoubleArray(initialDoubleArray);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -762,55 +762,4 @@ public class DescriptiveStatistics implements StatisticalSummary, Serializable {
|
|||
dest.skewnessImpl = source.skewnessImpl;
|
||||
dest.percentileImpl = source.percentileImpl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a method to compute a statistics on the contents of the
|
||||
* array.
|
||||
*/
|
||||
private static class StatArray extends ResizableDoubleArray {
|
||||
/** Default constructor. */
|
||||
public StatArray() {}
|
||||
|
||||
/**
|
||||
* Builds an instance with the same contents as the given array.
|
||||
*
|
||||
* @param initialArray Data.
|
||||
*/
|
||||
public StatArray(double[] initialArray) {
|
||||
super(initialArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a copy of the given instance.
|
||||
*
|
||||
* @param other Array.
|
||||
* @throws NullArgumentException if the argument is {@code null}.
|
||||
*/
|
||||
public StatArray(StatArray other)
|
||||
throws NullArgumentException {
|
||||
super(other);
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the given statistics from the contents of this array.
|
||||
*
|
||||
* @param stat Statistics.
|
||||
* @return the result of evaluating the statistics on the current
|
||||
* contents of this array.
|
||||
*/
|
||||
public double compute(UnivariateStatistic stat) {
|
||||
return stat.evaluate(getArrayRef(),
|
||||
getStartIndex(),
|
||||
getNumElements());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a copy of this instance.
|
||||
*
|
||||
* @return a copy of this instance.
|
||||
*/
|
||||
public StatArray copy() {
|
||||
return new StatArray(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.apache.commons.math3.stat.descriptive;
|
||||
|
||||
import org.apache.commons.math3.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.math3.util.MathArrays;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -24,8 +25,7 @@ import org.apache.commons.math3.exception.MathIllegalArgumentException;
|
|||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface UnivariateStatistic {
|
||||
|
||||
public interface UnivariateStatistic extends MathArrays.Function {
|
||||
/**
|
||||
* Returns the result of evaluating the statistic over the input array.
|
||||
*
|
||||
|
@ -53,5 +53,4 @@ public interface UnivariateStatistic {
|
|||
* @return a copy of the statistic
|
||||
*/
|
||||
UnivariateStatistic copy();
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue