本文整理汇总了Java中org.apache.commons.math3.stat.descriptive.rank.Percentile.EstimationType类的典型用法代码示例。如果您正苦于以下问题:Java EstimationType类的具体用法?Java EstimationType怎么用?Java EstimationType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EstimationType类属于org.apache.commons.math3.stat.descriptive.rank.Percentile包,在下文中一共展示了EstimationType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAllTechniquesSingleton
import org.apache.commons.math3.stat.descriptive.rank.Percentile.EstimationType; //导入依赖的package包/类
@Test
public void testAllTechniquesSingleton() {
double[] singletonArray = new double[] { 1d };
for (EstimationType e : EstimationType.values()) {
UnivariateStatistic percentile = getTestMedian(e);
Assert.assertEquals(1d, percentile.evaluate(singletonArray), 0);
Assert.assertEquals(1d, percentile.evaluate(singletonArray, 0, 1),
0);
Assert.assertEquals(1d,
new Median().evaluate(singletonArray, 0, 1, 5), 0);
Assert.assertEquals(1d,
new Median().evaluate(singletonArray, 0, 1, 100), 0);
Assert.assertTrue(Double.isNaN(percentile.evaluate(singletonArray,
0, 0)));
}
}
示例2: testAllTechniquesNISTExample
import org.apache.commons.math3.stat.descriptive.rank.Percentile.EstimationType; //导入依赖的package包/类
@Test
public void testAllTechniquesNISTExample() {
final double[] d =
new double[] { 95.1772, 95.1567, 95.1937, 95.1959, 95.1442,
95.0610, 95.1591, 95.1195, 95.1772, 95.0925, 95.1990,
95.1682 };
testAssertMappedValues(d, new Object[][] { { Percentile.EstimationType.LEGACY, 95.1981 },
{ Percentile.EstimationType.R_1, 95.19590 }, { Percentile.EstimationType.R_2, 95.19590 }, { Percentile.EstimationType.R_3, 95.19590 },
{ Percentile.EstimationType.R_4, 95.19546 }, { Percentile.EstimationType.R_5, 95.19683 }, { Percentile.EstimationType.R_6, 95.19807 },
{ Percentile.EstimationType.R_7, 95.19568 }, { Percentile.EstimationType.R_8, 95.19724 }, { Percentile.EstimationType.R_9, 95.19714 } }, 90d,
1.0e-04);
for (final Percentile.EstimationType e : Percentile.EstimationType.values()) {
reset(100.0, e);
Assert.assertEquals(95.1990, getUnivariateStatistic().evaluate(d), 1.0e-4);
}
}
示例3: testAllTechniquesNullEmpty
import org.apache.commons.math3.stat.descriptive.rank.Percentile.EstimationType; //导入依赖的package包/类
@Test
public void testAllTechniquesNullEmpty() {
final double[] nullArray = null;
final double[] emptyArray = new double[] {};
for (final Percentile.EstimationType e : Percentile.EstimationType.values()) {
reset (50, e);
final UnivariateStatistic percentile = getUnivariateStatistic();
try {
percentile.evaluate(nullArray);
Assert.fail("Expecting MathIllegalArgumentException "
+ "for null array");
} catch (final MathIllegalArgumentException ex) {
// expected
}
Assert.assertTrue(Double.isNaN(percentile.evaluate(emptyArray)));
}
}
示例4: testAllTechniquesSingleton
import org.apache.commons.math3.stat.descriptive.rank.Percentile.EstimationType; //导入依赖的package包/类
@Test
public void testAllTechniquesSingleton() {
final double[] singletonArray = new double[] { 1d };
for (final Percentile.EstimationType e : Percentile.EstimationType.values()) {
reset (50, e);
final UnivariateStatistic percentile = getUnivariateStatistic();
Assert.assertEquals(1d, percentile.evaluate(singletonArray), 0);
Assert.assertEquals(1d, percentile.evaluate(singletonArray, 0, 1),
0);
Assert.assertEquals(1d,
new Percentile().evaluate(singletonArray, 0, 1, 5), 0);
Assert.assertEquals(1d,
new Percentile().evaluate(singletonArray, 0, 1, 100), 0);
Assert.assertTrue(Double.isNaN(percentile.evaluate(singletonArray,
0, 0)));
}
}
示例5: testAllTechniquesEmpty
import org.apache.commons.math3.stat.descriptive.rank.Percentile.EstimationType; //导入依赖的package包/类
@Test
public void testAllTechniquesEmpty() {
final double[] singletonArray = new double[] { };
for (final Percentile.EstimationType e : Percentile.EstimationType.values()) {
reset (50, e);
final UnivariateStatistic percentile = getUnivariateStatistic();
Assert.assertEquals(Double.NaN, percentile.evaluate(singletonArray),
0);
Assert.assertEquals(Double.NaN, percentile.evaluate(singletonArray,
0, 0),
0);
Assert.assertEquals(Double.NaN,
new Percentile().evaluate(singletonArray, 0, 0, 5), 0);
Assert.assertEquals(Double.NaN,
new Percentile().evaluate(singletonArray, 0, 0, 100), 0);
Assert.assertTrue(Double.isNaN(percentile.evaluate(singletonArray,
0, 0)));
}
}
示例6: testRemoveNan
import org.apache.commons.math3.stat.descriptive.rank.Percentile.EstimationType; //导入依赖的package包/类
@Test
public void testRemoveNan() {
final double[] specialValues =
new double[] { 0d, 1d, 2d, 3d, 4d, Double.NaN };
final double[] expectedValues =
new double[] { 0d, 1d, 2d, 3d, 4d };
reset (50, Percentile.EstimationType.R_1);
Assert.assertEquals(2.0, getUnivariateStatistic().evaluate(specialValues), 0d);
Assert.assertEquals(2.0, getUnivariateStatistic().evaluate(expectedValues),0d);
Assert.assertTrue(Double.isNaN(getUnivariateStatistic().evaluate(specialValues,5,1)));
Assert.assertEquals(4d, getUnivariateStatistic().evaluate(specialValues, 4, 2), 0d);
Assert.assertEquals(3d, getUnivariateStatistic().evaluate(specialValues,3,3),0d);
reset(50, Percentile.EstimationType.R_2);
Assert.assertEquals(3.5d, getUnivariateStatistic().evaluate(specialValues,3,3),0d);
}
示例7: testStoredVsDirect
import org.apache.commons.math3.stat.descriptive.rank.Percentile.EstimationType; //导入依赖的package包/类
@Test
public void testStoredVsDirect() {
final RandomGenerator rand= new JDKRandomGenerator();
rand.setSeed(Long.MAX_VALUE);
for (final int sampleSize:sampleSizes) {
final double[] data = new NormalDistribution(rand,4000, 50)
.sample(sampleSize);
for (final double p:new double[] {50d,95d}) {
for (final Percentile.EstimationType e : Percentile.EstimationType.values()) {
reset(p, e);
final Percentile pStoredData = getUnivariateStatistic();
pStoredData.setData(data);
final double storedDataResult=pStoredData.evaluate();
pStoredData.setData(null);
final Percentile pDirect = getUnivariateStatistic();
Assert.assertEquals("Sample="+sampleSize+",P="+p+" e="+e,
storedDataResult,
pDirect.evaluate(data),0d);
}
}
}
}
示例8: testAllEstimationTechniquesOnlyForExtremeIndexes
import org.apache.commons.math3.stat.descriptive.rank.Percentile.EstimationType; //导入依赖的package包/类
@Test
public void testAllEstimationTechniquesOnlyForExtremeIndexes() {
final double MAX=100;
final Object[][] map =
new Object[][] { { Percentile.EstimationType.LEGACY, 0d, MAX}, { Percentile.EstimationType.R_1, 0d,MAX+0.5 },
{ Percentile.EstimationType.R_2, 0d,MAX}, { Percentile.EstimationType.R_3, 0d,MAX }, { Percentile.EstimationType.R_4, 0d,MAX },
{ Percentile.EstimationType.R_5, 0d,MAX }, { Percentile.EstimationType.R_6, 0d,MAX },
{ Percentile.EstimationType.R_7, 0d,MAX }, { Percentile.EstimationType.R_8, 0d,MAX }, { Percentile.EstimationType.R_9, 0d,MAX } };
for (final Object[] o : map) {
final Percentile.EstimationType e = (Percentile.EstimationType) o[0];
Assert.assertEquals(((Double)o[1]).doubleValue(),
e.index(0d, (int)MAX),0d);
Assert.assertEquals("Enum:"+e,((Double)o[2]).doubleValue(),
e.index(1.0, (int)MAX),0d);
}
}
示例9: testAllEstimationTechniquesOnlyForNullsAndOOR
import org.apache.commons.math3.stat.descriptive.rank.Percentile.EstimationType; //导入依赖的package包/类
@Test
public void testAllEstimationTechniquesOnlyForNullsAndOOR() {
final Object[][] map =
new Object[][] { { Percentile.EstimationType.LEGACY, 20.82 }, { Percentile.EstimationType.R_1, 19.8 },
{ Percentile.EstimationType.R_2, 19.8 }, { Percentile.EstimationType.R_3, 19.8 }, { Percentile.EstimationType.R_4, 19.310 },
{ Percentile.EstimationType.R_5, 20.280}, { Percentile.EstimationType.R_6, 20.820},
{ Percentile.EstimationType.R_7, 19.555 }, { Percentile.EstimationType.R_8, 20.460 },{ Percentile.EstimationType.R_9, 20.415 } };
for (final Object[] o : map) {
final Percentile.EstimationType e = (Percentile.EstimationType) o[0];
try {
e.evaluate(null, DEFAULT_PERCENTILE, new KthSelector());
Assert.fail("Expecting NullArgumentException");
} catch (final NullArgumentException nae) {
// expected
}
try {
e.evaluate(testArray, 120, new KthSelector());
Assert.fail("Expecting OutOfRangeException");
} catch (final OutOfRangeException oore) {
// expected
}
}
}
示例10: testAssertMappedValues
import org.apache.commons.math3.stat.descriptive.rank.Percentile.EstimationType; //导入依赖的package包/类
/**
* Simple test assertion utility method assuming {@link NaNStrategy default}
* nan handling strategy specific to each {@link EstimationType type}
*
* @param data input data
* @param map of expected result against a {@link EstimationType}
* @param p the quantile to compute for
* @param tolerance the tolerance of difference allowed
*/
protected void testAssertMappedValues(final double[] data, final Object[][] map,
final Double p, final Double tolerance) {
for (final Object[] o : map) {
final Percentile.EstimationType e = (Percentile.EstimationType) o[0];
final double expected = (Double) o[1];
try {
reset(p, e);
final double result = getUnivariateStatistic().evaluate(data);
Assert.assertEquals("expected[" + e + "] = " + expected +
" but was = " + result, expected, result, tolerance);
} catch(final Exception ex) {
Assert.fail("Exception occured for estimation type "+e+":"+
ex.getLocalizedMessage());
}
}
}
示例11: testNanStrategySpecific
import org.apache.commons.math3.stat.descriptive.rank.Percentile.EstimationType; //导入依赖的package包/类
@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);
specialValues = new double[] { 0d, 1d, 2d, 3d, 4d, Double.NaN, Double.NaN };
Assert.assertEquals(3.5,new Percentile().evaluate(specialValues, 3, 4),0d);
Assert.assertEquals(4d,new Percentile().evaluate(specialValues, 4, 3),0d);
Assert.assertTrue(Double.isNaN(new Percentile().evaluate(specialValues, 5, 2)));
specialValues = new double[] { 0d, 1d, 2d, 3d, 4d, Double.NaN, Double.NaN, 5d, 6d };
Assert.assertEquals(4.5,new Percentile().evaluate(specialValues, 3, 6),0d);
Assert.assertEquals(5d,new Percentile().evaluate(specialValues, 4, 5),0d);
Assert.assertTrue(Double.isNaN(new Percentile().evaluate(specialValues, 5, 2)));
Assert.assertTrue(Double.isNaN(new Percentile().evaluate(specialValues, 5, 1)));
Assert.assertEquals(5.5,new Percentile().evaluate(specialValues, 5, 4),0d);
}
示例12: testAssertMappedValues
import org.apache.commons.math3.stat.descriptive.rank.Percentile.EstimationType; //导入依赖的package包/类
/**
* Simple test assertion utility method
*
* @param d input data
* @param map of expected result against a {@link EstimationType}
* @param tolerance the tolerance of difference allowed
*/
protected void testAssertMappedValues(double[] d, Object[][] map,
Double tolerance) {
for (Object[] o : map) {
EstimationType e = (EstimationType) o[0];
double expected = (Double) o[1];
double result = getTestMedian(e).evaluate(d);
Assert.assertEquals("expected[" + e + "] = " + expected +
" but was = " + result, expected, result, tolerance);
}
}
示例13: before
import org.apache.commons.math3.stat.descriptive.rank.Percentile.EstimationType; //导入依赖的package包/类
/**
* Before method to ensure defaults retained
*/
@Before
public void before() {
quantile = 95.0;
type = Percentile.EstimationType.LEGACY;
nanStrategy = NaNStrategy.REMOVED;
kthSelector = new KthSelector(new MedianOf3PivotingStrategy());
}
示例14: testAllTechniquesHighPercentile
import org.apache.commons.math3.stat.descriptive.rank.Percentile.EstimationType; //导入依赖的package包/类
/**
* While {@link #testHighPercentile()} checks only for the existing
* implementation; this method verifies for all the types including Percentile.Type.CM Percentile.Type.
*/
@Test
public void testAllTechniquesHighPercentile() {
final double[] d = new double[] { 1, 2, 3 };
testAssertMappedValues(d, new Object[][] { { Percentile.EstimationType.LEGACY, 3d }, { Percentile.EstimationType.R_1, 3d },
{ Percentile.EstimationType.R_2, 3d }, { Percentile.EstimationType.R_3, 2d }, { Percentile.EstimationType.R_4, 2.25 }, { Percentile.EstimationType.R_5, 2.75 },
{ Percentile.EstimationType.R_6, 3d }, { Percentile.EstimationType.R_7, 2.5 },{ Percentile.EstimationType.R_8, 2.83333 }, {Percentile.EstimationType.R_9,2.81250} },
75d, 1.0e-5);
}
示例15: testAllTechniquesLowPercentile
import org.apache.commons.math3.stat.descriptive.rank.Percentile.EstimationType; //导入依赖的package包/类
@Test
public void testAllTechniquesLowPercentile() {
final double[] d = new double[] { 0, 1 };
testAssertMappedValues(d, new Object[][] { { Percentile.EstimationType.LEGACY, 0d }, { Percentile.EstimationType.R_1, 0d },
{ Percentile.EstimationType.R_2, 0d }, { Percentile.EstimationType.R_3, 0d }, { Percentile.EstimationType.R_4, 0d }, {Percentile.EstimationType.R_5, 0d}, {Percentile.EstimationType.R_6, 0d},
{ Percentile.EstimationType.R_7, 0.25 }, { Percentile.EstimationType.R_8, 0d }, {Percentile.EstimationType.R_9, 0d} },
25d, Double.MIN_VALUE);
}