Replaced calls to deprecated methods in "ResizeableDoubleArray" (see
MATH-894). Created subclass of "ResizeableDoubleArray" in order to access to the object's internal array. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1409509 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
615661c90f
commit
b06f4a4ac6
|
@ -79,7 +79,7 @@ public class DescriptiveStatistics implements StatisticalSummary, Serializable {
|
|||
/**
|
||||
* Stored data values
|
||||
*/
|
||||
private ResizableDoubleArray eDA = new ResizableDoubleArray();
|
||||
private StatArray eDA = new StatArray();
|
||||
|
||||
/** 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 ResizableDoubleArray(initialDoubleArray);
|
||||
eDA = new StatArray(initialDoubleArray);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -484,7 +484,7 @@ public class DescriptiveStatistics implements StatisticalSummary, Serializable {
|
|||
*/
|
||||
public double apply(UnivariateStatistic stat) {
|
||||
// No try-catch or advertised exception here because arguments are guaranteed valid
|
||||
return stat.evaluate(eDA.getInternalValues(), eDA.start(), eDA.getNumElements());
|
||||
return eDA.compute(stat);
|
||||
}
|
||||
|
||||
// Implementation getters and setter
|
||||
|
@ -762,4 +762,55 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue