Percentile extends AbstractUnivariateStatistic implements Serializable { private static double[] copyOf(final double[] values, final int begin, final int length) { MathArrays.verifyValues(values, begin, length); return MathArrays.copyOfRange(values, begin, begin + length); } Percentile();  Percentile(final double quantile);  Percentile(final Percentile original); protected  Percentile(final double quantile,
                         final EstimationType estimationType,
                         final NaNStrategy nanStrategy,
                         final KthSelector kthSelector); @Override void setData(final double[] values); @Override void setData(final double[] values, final int begin, final int length); double evaluate(final double p); double evaluate(final double[] values, final double p); @Override double evaluate(final double[] values, final int start, final int length); double evaluate(final double[] values, final int begin,
                           final int length, final double p); double getQuantile(); void setQuantile(final double p); @Override Percentile copy(); @Deprecated static void copy(final Percentile source, final Percentile dest); EstimationType getEstimationType(); Percentile withEstimationType(final EstimationType newEstimationType); NaNStrategy getNaNStrategy(); Percentile withNaNStrategy(final NaNStrategy newNaNStrategy); KthSelector getKthSelector(); PivotingStrategyInterface getPivotingStrategy(); Percentile withKthSelector(final KthSelector newKthSelector);  }
@Test public void testAllEstimationTechniquesOnlyLimits() { final int N=testArray.length; final double[] input=MathArrays.copyOf(testArray); Arrays.sort(input); final double min = input[0]; final double max=input[input.length-1]; final Object[][] map = new Object[][] { { Percentile.EstimationType.LEGACY, 0d, 1d }, { Percentile.EstimationType.R_1, 0d, 1d }, { Percentile.EstimationType.R_2, 0d,1d }, { Percentile.EstimationType.R_3, 0.5/N,1d }, { Percentile.EstimationType.R_4, 1d/N-0.001,1d }, { Percentile.EstimationType.R_5, 0.5/N-0.001,(N-0.5)/N}, { Percentile.EstimationType.R_6, 0.99d/(N+1), 1.01d*N/(N+1)}, { Percentile.EstimationType.R_7, 0d,1d}, { Percentile.EstimationType.R_8, 1.99d/3/(N+1d/3), (N-1d/3)/(N+1d/3)}, { Percentile.EstimationType.R_9, 4.99d/8/(N+0.25), (N-3d/8)/(N+0.25)} }; for(final Object[] arr:map) { final Percentile.EstimationType t= (Percentile.EstimationType) arr[0]; double pMin=(Double)arr[1]; final double pMax=(Double)arr[2]; Assert.assertEquals("Type:"+t,0d, t.index(pMin, N),0d); Assert.assertEquals("Type:"+t,N, t.index(pMax, N),0.5d); pMin=pMin==0d?pMin+0.01:pMin; testAssertMappedValues(testArray, new Object[][] { { t, min }}, pMin, 0.01); testAssertMappedValues(testArray, new Object[][] { { t, max }}, pMax * 100, tolerance); } }