diff --git a/src/main/java/org/apache/commons/math3/stat/descriptive/rank/Percentile.java b/src/main/java/org/apache/commons/math3/stat/descriptive/rank/Percentile.java index df2bdf44e..c963fad77 100644 --- a/src/main/java/org/apache/commons/math3/stat/descriptive/rank/Percentile.java +++ b/src/main/java/org/apache/commons/math3/stat/descriptive/rank/Percentile.java @@ -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)