Using method from "MathArrays".

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1604651 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gilles Sadowski 2014-06-22 20:12:41 +00:00
parent b69e6ca5c1
commit a4118e288f
1 changed files with 1 additions and 19 deletions

View File

@ -446,8 +446,8 @@ public class Percentile extends AbstractUnivariateStatistic implements Serializa
work = removeAndSlice(values, begin, length, Double.NaN);
break;
case FAILED:// just throw exception as NaN is un-acceptable
checkNotANumber(values, begin, length);
work = copyOf(values, begin, length);
MathArrays.checkNotNaN(work);
break;
default: //FIXED
work = copyOf(values,begin,length);
@ -457,24 +457,6 @@ public class Percentile extends AbstractUnivariateStatistic implements Serializa
return work;
}
/**
* Check the presence of {@link Double#NaN NaN} in a double array for the
* array slice defined by array part from [begin,begin+length) and throw an
* exception on detecting the first presence within the defined slice.
* @param values the input array
* @param begin start index of the array to include
* @param length number of elements to include from begin
* @throws NotANumberException if any of the values contain a NaN
*/
private static void checkNotANumber(final double[] values, final int begin, final int length) {
MathArrays.verifyValues(values, begin, length);
for(int i = begin; i < begin + length; i++) {
if(Double.isNaN(values[i])) {
throw new NotANumberException();
}
}
}
/**
* Make a copy of the array for the slice defined by array part from
* [begin, begin+length)