git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1605776 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gilles Sadowski 2014-06-26 13:05:24 +00:00
parent 61b2d1f34c
commit 75d4db00e1
4 changed files with 11 additions and 11 deletions

View File

@ -80,7 +80,7 @@ public class Median extends Percentile implements Serializable {
/** {@inheritDoc} */
@Override
public Median withEstimationtype(final EstimationType newEstimationType) {
public Median withEstimationType(final EstimationType newEstimationType) {
return new Median(newEstimationType, getNaNStrategy(), getPivotingStrategy());
}

View File

@ -590,7 +590,7 @@ public class Percentile extends AbstractUnivariateStatistic implements Serializa
* @return a new instance, with changed pivoting strategy
* @throws NullArgumentException when pivotingStrategy is null
*/
public Percentile withEstimationtype(final EstimationType newEstimationType) {
public Percentile withEstimationType(final EstimationType newEstimationType) {
return new Percentile(quantile, newEstimationType, nanStrategy, pivotingStrategy);
}

View File

@ -60,7 +60,7 @@ public class MedianTest extends UnivariateStatisticAbstractTest{
private Median getTestMedian(EstimationType type) {
NaNStrategy strategy = (type == LEGACY) ? NaNStrategy.FIXED : NaNStrategy.REMOVED;
return new Median().withEstimationtype(type).withNaNStrategy(strategy);
return new Median().withEstimationType(type).withNaNStrategy(strategy);
}
/**

View File

@ -90,7 +90,7 @@ public class PercentileTest extends UnivariateStatisticAbstractTest{
@Override
public Percentile getUnivariateStatistic() {
return new Percentile(quantile).
withEstimationtype(type).
withEstimationType(type).
withNaNStrategy(nanStrategy).
withPivotingStrategy(pivotingStrategy);
}
@ -776,10 +776,10 @@ public class PercentileTest extends UnivariateStatisticAbstractTest{
@Test
public void testNanStrategySpecific() {
double[] specialValues = new double[] { 0d, 1d, 2d, 3d, 4d, Double.NaN };
Assert.assertTrue(Double.isNaN(new Percentile(50d).withEstimationtype(Percentile.EstimationType.LEGACY).withNaNStrategy(NaNStrategy.MAXIMAL).evaluate(specialValues, 3, 3)));
Assert.assertEquals(2d,new Percentile(50d).withEstimationtype(Percentile.EstimationType.R_1).withNaNStrategy(NaNStrategy.REMOVED).evaluate(specialValues),0d);
Assert.assertEquals(Double.NaN,new Percentile(50d).withEstimationtype(Percentile.EstimationType.R_5).withNaNStrategy(NaNStrategy.REMOVED).evaluate(new double[] {Double.NaN,Double.NaN,Double.NaN}),0d);
Assert.assertEquals(50d,new Percentile(50d).withEstimationtype(Percentile.EstimationType.R_7).withNaNStrategy(NaNStrategy.MINIMAL).evaluate(new double[] {50d,50d,50d},1,2),0d);
Assert.assertTrue(Double.isNaN(new Percentile(50d).withEstimationType(Percentile.EstimationType.LEGACY).withNaNStrategy(NaNStrategy.MAXIMAL).evaluate(specialValues, 3, 3)));
Assert.assertEquals(2d,new Percentile(50d).withEstimationType(Percentile.EstimationType.R_1).withNaNStrategy(NaNStrategy.REMOVED).evaluate(specialValues),0d);
Assert.assertEquals(Double.NaN,new Percentile(50d).withEstimationType(Percentile.EstimationType.R_5).withNaNStrategy(NaNStrategy.REMOVED).evaluate(new double[] {Double.NaN,Double.NaN,Double.NaN}),0d);
Assert.assertEquals(50d,new Percentile(50d).withEstimationType(Percentile.EstimationType.R_7).withNaNStrategy(NaNStrategy.MINIMAL).evaluate(new double[] {50d,50d,50d},1,2),0d);
}
// Some NaNStrategy specific testing
@ -788,7 +788,7 @@ public class PercentileTest extends UnivariateStatisticAbstractTest{
double[] specialValues =
new double[] { 0d, 1d, 2d, 3d, 4d, Double.NaN };
new Percentile(50d).
withEstimationtype(Percentile.EstimationType.R_9).
withEstimationType(Percentile.EstimationType.R_9).
withNaNStrategy(NaNStrategy.FAILED).
evaluate(specialValues, 3, 3);
}
@ -798,7 +798,7 @@ public class PercentileTest extends UnivariateStatisticAbstractTest{
double[] specialValues =
new double[] { 0d, 1d, 2d, 3d, 4d, Double.NaN };
try {
new Percentile(50d).withEstimationtype(Percentile.EstimationType.LEGACY).withNaNStrategy(null);
new Percentile(50d).withEstimationType(Percentile.EstimationType.LEGACY).withNaNStrategy(null);
Assert.fail("Expecting NullArgumentArgumentException "
+ "for null Nan Strategy");
} catch (NullArgumentException ex) {
@ -848,7 +848,7 @@ public class PercentileTest extends UnivariateStatisticAbstractTest{
Percentile.EstimationType e = (Percentile.EstimationType) o[0];
double expected = (Double) o[1];
try {
double result = new Percentile(p).withEstimationtype(e).withNaNStrategy(nanStrategy).evaluate(data);
double result = new Percentile(p).withEstimationType(e).withNaNStrategy(nanStrategy).evaluate(data);
Assert.assertEquals("expected[" + e + "] = " + expected +
" but was = " + result, expected, result, tolerance);
}catch(Exception ex) {