}
@Test
public void testAllTechniquesSpecialValues() {
reset(50d, Percentile.EstimationType.LEGACY);
final UnivariateStatistic percentile = getUnivariateStatistic();
double[] specialValues =
new double[] { 0d, 1d, 2d, 3d, 4d, Double.NaN };
Assert.assertEquals(2.5d, percentile.evaluate(specialValues), 0);
testAssertMappedValues(specialValues, new Object[][] {
{ Percentile.EstimationType.LEGACY, 2.5d }, { Percentile.EstimationType.R_1, 2.0 }, { Percentile.EstimationType.R_2, 2.0 }, { Percentile.EstimationType.R_3, 1.0 },
{ Percentile.EstimationType.R_4, 1.5 }, { Percentile.EstimationType.R_5, 2.0 }, { Percentile.EstimationType.R_6, 2.0 },
{ Percentile.EstimationType.R_7, 2.0 }, { Percentile.EstimationType.R_8, 2.0 }, { Percentile.EstimationType.R_9, 2.0 }}, 50d, 0d);
specialValues =
new double[] { Double.NEGATIVE_INFINITY, 1d, 2d, 3d,
Double.NaN, Double.POSITIVE_INFINITY };
Assert.assertEquals(2.5d, percentile.evaluate(specialValues), 0);
testAssertMappedValues(specialValues, new Object[][] {
{ Percentile.EstimationType.LEGACY, 2.5d }, { Percentile.EstimationType.R_1, 2.0 }, { Percentile.EstimationType.R_2, 2.0 }, { Percentile.EstimationType.R_3, 1.0 },
{ Percentile.EstimationType.R_4, 1.5 }, { Percentile.EstimationType.R_5, 2.0 }, { Percentile.EstimationType.R_7, 2.0 }, { Percentile.EstimationType.R_7, 2.0 },
{ Percentile.EstimationType.R_8, 2.0 }, { Percentile.EstimationType.R_9, 2.0 } }, 50d, 0d);
specialValues =
new double[] { 1d, 1d, Double.POSITIVE_INFINITY,
Double.POSITIVE_INFINITY };
Assert.assertTrue(Double.isInfinite(percentile.evaluate(specialValues)));
testAssertMappedValues(specialValues, new Object[][] {
// This is one test not matching with R results.
{ Percentile.EstimationType.LEGACY, Double.POSITIVE_INFINITY },
{ Percentile.EstimationType.R_1,/* 1.0 */Double.NaN },
{ Percentile.EstimationType.R_2, /* Double.POSITIVE_INFINITY */Double.NaN },
{ Percentile.EstimationType.R_3, /* 1.0 */Double.NaN }, { Percentile.EstimationType.R_4, /* 1.0 */Double.NaN },
{ Percentile.EstimationType.R_5, Double.POSITIVE_INFINITY },
{ Percentile.EstimationType.R_6, Double.POSITIVE_INFINITY },
{ Percentile.EstimationType.R_7, Double.POSITIVE_INFINITY },
{ Percentile.EstimationType.R_8, Double.POSITIVE_INFINITY },
{ Percentile.EstimationType.R_9, Double.POSITIVE_INFINITY }, }, 50d, 0d);
specialValues = new double[] { 1d, 1d, Double.NaN, Double.NaN };
Assert.assertTrue(Double.isNaN(percentile.evaluate(specialValues)));
testAssertMappedValues(specialValues, new Object[][] {
{ Percentile.EstimationType.LEGACY, Double.NaN }, { Percentile.EstimationType.R_1, 1.0 }, { Percentile.EstimationType.R_2, 1.0 }, { Percentile.EstimationType.R_3, 1.0 },
{ Percentile.EstimationType.R_4, 1.0 }, { Percentile.EstimationType.R_5, 1.0 },{ Percentile.EstimationType.R_6, 1.0 },{ Percentile.EstimationType.R_7, 1.0 },
{ Percentile.EstimationType.R_8, 1.0 }, { Percentile.EstimationType.R_9, 1.0 },}, 50d, 0d);