当前位置: 首页>>代码示例>>Java>>正文


Java Frequency.getCount方法代码示例

本文整理汇总了Java中org.apache.commons.math.stat.Frequency.getCount方法的典型用法代码示例。如果您正苦于以下问题:Java Frequency.getCount方法的具体用法?Java Frequency.getCount怎么用?Java Frequency.getCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.math.stat.Frequency的用法示例。


在下文中一共展示了Frequency.getCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: frequencyToStatistics

import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
public static DescriptiveStatistics frequencyToStatistics(Frequency frequency)
{
    Iterator<Comparable<?>> comparableIterator = frequency.valuesIterator();
    DescriptiveStatistics result = new DescriptiveStatistics();
    while (comparableIterator.hasNext()) {
        Comparable<?> next = comparableIterator.next();
        long count = frequency.getCount(next);

        for (int i = 0; i < count; i++) {
            if (next instanceof Number) {
                result.addValue(((Number) next).doubleValue());
            }
        }
    }

    return result;
}
 
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:18,代码来源:CollectionUtils.java

示例2: testNextInt

import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
/** test dispersion and failure modes for nextInt() */
public void testNextInt() {
    try {
        randomData.nextInt(4,3);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException ex) {
        ;
    }
    Frequency freq = new Frequency();
    int value = 0;
    for (int i=0;i<smallSampleSize;i++) {
        value = randomData.nextInt(0,3);
        assertTrue("nextInt range",(value >= 0) && (value <= 3));
        freq.addValue(value);  
    }
    long[] observed = new long[4];
    for (int i=0; i<4; i++) {
        observed[i] = freq.getCount(i);
    } 
    
    /* Use ChiSquare dist with df = 4-1 = 3, alpha = .001
     * Change to 11.34 for alpha = .01
     */
    assertTrue("chi-square test -- will fail about 1 in 1000 times",
        testStatistic.chiSquare(expected,observed) < 16.27);    
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:27,代码来源:RandomDataTest.java

示例3: testNextLong

import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
/** test dispersion and failure modes for nextLong() */
public void testNextLong() {
   try {
        randomData.nextLong(4,3);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException ex) {
        ;
    }
   Frequency freq = new Frequency();
   long value = 0;
    for (int i=0;i<smallSampleSize;i++) {
        value = randomData.nextLong(0,3);
        assertTrue("nextInt range",(value >= 0) && (value <= 3));
        freq.addValue(value);  
    }
    long[] observed = new long[4];
    for (int i=0; i<4; i++) {
        observed[i] = freq.getCount(i);
    } 
    
    /* Use ChiSquare dist with df = 4-1 = 3, alpha = .001
     * Change to 11.34 for alpha = .01
     */
    assertTrue("chi-square test -- will fail about 1 in 1000 times",
        testStatistic.chiSquare(expected,observed) < 16.27);    
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:27,代码来源:RandomDataTest.java

示例4: testNextSecureLong

import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
/** test dispersion and failure modes for nextSecureLong() */
public void testNextSecureLong() {
    try {
        randomData.nextSecureLong(4,3);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException ex) {
        ;
    }
    Frequency freq = new Frequency();
    long value = 0;
    for (int i=0;i<smallSampleSize;i++) {
        value = randomData.nextSecureLong(0,3);
        assertTrue("nextInt range",(value >= 0) && (value <= 3));
        freq.addValue(value);  
    }
    long[] observed = new long[4];
    for (int i=0; i<4; i++) {
        observed[i] = freq.getCount(i);
    } 
    
    /* Use ChiSquare dist with df = 4-1 = 3, alpha = .001
     * Change to 11.34 for alpha = .01
     */
    assertTrue("chi-square test -- will fail about 1 in 1000 times",
        testStatistic.chiSquare(expected,observed) < 16.27);    
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:27,代码来源:RandomDataTest.java

示例5: testNextSecureInt

import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
/** test dispersion and failure modes for nextSecureInt() */
public void testNextSecureInt() {
    try {
        randomData.nextSecureInt(4,3);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException ex) {
        ;
    }
    Frequency freq = new Frequency();
    int value = 0;
    for (int i=0;i<smallSampleSize;i++) {
        value = randomData.nextSecureInt(0,3);
        assertTrue("nextInt range",(value >= 0) && (value <= 3));
        freq.addValue(value);  
    }
    long[] observed = new long[4];
    for (int i=0; i<4; i++) {
        observed[i] = freq.getCount(i);
    } 
    
    /* Use ChiSquare dist with df = 4-1 = 3, alpha = .001
     * Change to 11.34 for alpha = .01
     */
    assertTrue("chi-square test -- will fail about 1 in 1000 times",
        testStatistic.chiSquare(expected,observed) < 16.27);    
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:27,代码来源:RandomDataTest.java

示例6: testNextInt

import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
public void testNextInt() {
    try {
        testGenerator.nextInt(-1);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException ex) {
        ;
    }
    Frequency freq = new Frequency();
    int value = 0;
    for (int i=0; i<smallSampleSize; i++) {
        value = testGenerator.nextInt(4);
        assertTrue("nextInt range",(value >= 0) && (value <= 3));
        freq.addValue(value);  
    }
    long[] observed = new long[4];
    for (int i=0; i<4; i++) {
        observed[i] = freq.getCount(i);
    } 
    
    /* Use ChiSquare dist with df = 4-1 = 3, alpha = .001
     * Change to 11.34 for alpha = .01
     */
    assertTrue("chi-square test -- will fail about 1 in 1000 times",
            testStatistic.chiSquare(expected,observed) < 16.27);    
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:26,代码来源:AbstractRandomGeneratorTest.java

示例7: testNextInt

import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
@Override
public void testNextInt() {
    try {
        testGenerator.nextInt(-1);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException ex) {
        // ignored
    }
    Frequency freq = new Frequency();
    int value = 0;
    for (int i=0; i<smallSampleSize; i++) {
        value = testGenerator.nextInt(4);
        assertTrue("nextInt range",(value >= 0) && (value <= 3));
        freq.addValue(value);  
    }
    long[] observed = new long[4];
    for (int i=0; i<4; i++) {
        observed[i] = freq.getCount(i);
    } 
    
    /* Use ChiSquare dist with df = 4-1 = 3, alpha = .001
     * Change to 11.34 for alpha = .01
     */
    assertTrue("chi-square test -- will fail about 1 in 1000 times",
            testStatistic.chiSquare(expected,observed) < 16.27);    
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:27,代码来源:AbstractRandomGeneratorTest.java

示例8: testNextInt

import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
/** test dispersion and failure modes for nextInt() */
public void testNextInt() {
    try {
        int x = randomData.nextInt(4,3);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException ex) {
        ;
    }
    Frequency freq = new Frequency();
    int value = 0;
    for (int i=0;i<smallSampleSize;i++) {
        value = randomData.nextInt(0,3);
        assertTrue("nextInt range",(value >= 0) && (value <= 3));
        freq.addValue(value);  
    }
    long[] observed = new long[4];
    for (int i=0; i<4; i++) {
        observed[i] = freq.getCount(i);
    } 
    
    /* Use ChiSquare dist with df = 4-1 = 3, alpha = .001
     * Change to 11.34 for alpha = .01
     */
    assertTrue("chi-square test -- will fail about 1 in 1000 times",
        testStatistic.chiSquare(expected,observed) < 16.27);    
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:27,代码来源:RandomDataTest.java

示例9: testNextSecureInt

import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
/** test dispersion and failure modes for nextSecureInt() */
public void testNextSecureInt() {
    try {
        long x = randomData.nextSecureInt(4,3);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException ex) {
        ;
    }
    Frequency freq = new Frequency();
    int value = 0;
    for (int i=0;i<smallSampleSize;i++) {
        value = randomData.nextSecureInt(0,3);
        assertTrue("nextInt range",(value >= 0) && (value <= 3));
        freq.addValue(value);  
    }
    long[] observed = new long[4];
    for (int i=0; i<4; i++) {
        observed[i] = freq.getCount(i);
    } 
    
    /* Use ChiSquare dist with df = 4-1 = 3, alpha = .001
     * Change to 11.34 for alpha = .01
     */
    assertTrue("chi-square test -- will fail about 1 in 1000 times",
        testStatistic.chiSquare(expected,observed) < 16.27);    
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:27,代码来源:RandomDataTest.java

示例10: testNextLong

import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
/** test dispersion and failure modes for nextLong() */
public void testNextLong() {
   try {
        long x = randomData.nextLong(4,3);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException ex) {
        ;
    }
   Frequency freq = new Frequency();
   long value = 0;
    for (int i=0;i<smallSampleSize;i++) {
        value = randomData.nextLong(0,3);
        assertTrue("nextInt range",(value >= 0) && (value <= 3));
        freq.addValue(value);  
    }
    long[] observed = new long[4];
    for (int i=0; i<4; i++) {
        observed[i] = freq.getCount(i);
    } 
    
    /* Use ChiSquare dist with df = 4-1 = 3, alpha = .001
     * Change to 11.34 for alpha = .01
     */
    assertTrue("chi-square test -- will fail about 1 in 1000 times",
        testStatistic.chiSquare(expected,observed) < 16.27);    
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:27,代码来源:RandomDataTest.java

示例11: testNextLong

import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
public void testNextLong() {
    long q1 = Long.MAX_VALUE/4;
    long q2 = 2 *  q1;
    long q3 = 3 * q1;
    
    Frequency freq = new Frequency();
    long val = 0;
    int value = 0;
    for (int i=0; i<smallSampleSize; i++) {
        val = testGenerator.nextLong();
        if (val < q1) {
            value = 0;
        } else if (val < q2) {
            value = 1;
        } else if (val < q3) {
            value = 2;
        } else {
            value = 3;
        }
        freq.addValue(value);  
    }
    long[] observed = new long[4];
    for (int i=0; i<4; i++) {
        observed[i] = freq.getCount(i);
    } 
    
    /* Use ChiSquare dist with df = 4-1 = 3, alpha = .001
     * Change to 11.34 for alpha = .01
     */
    assertTrue("chi-square test -- will fail about 1 in 1000 times",
            testStatistic.chiSquare(expected,observed) < 16.27);    
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:33,代码来源:AbstractRandomGeneratorTest.java

示例12: testNextFloat

import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
public void testNextFloat() {
    Frequency freq = new Frequency();
    float val = 0;
    int value = 0;
    for (int i=0; i<smallSampleSize; i++) {
        val = testGenerator.nextFloat();
        if (val < 0.25) {
            value = 0;
        } else if (val < 0.5) {
            value = 1;
        } else if (val < 0.75) {
            value = 2;
        } else {
            value = 3;
        }
        freq.addValue(value);  
    }
    long[] observed = new long[4];
    for (int i=0; i<4; i++) {
        observed[i] = freq.getCount(i);
    } 
    
    /* Use ChiSquare dist with df = 4-1 = 3, alpha = .001
     * Change to 11.34 for alpha = .01
     */
    assertTrue("chi-square test -- will fail about 1 in 1000 times",
            testStatistic.chiSquare(expected,observed) < 16.27);    
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:29,代码来源:AbstractRandomGeneratorTest.java

示例13: testNextInt

import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
/** test dispersion and failure modes for nextInt() */
public void testNextInt() {
    try {
        randomData.nextInt(4, 3);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException ex) {
        // ignored
    }
    Frequency freq = new Frequency();
    int value = 0;
    for (int i = 0; i < smallSampleSize; i++) {
        value = randomData.nextInt(0, 3);
        assertTrue("nextInt range", (value >= 0) && (value <= 3));
        freq.addValue(value);
    }
    long[] observed = new long[4];
    for (int i = 0; i < 4; i++) {
        observed[i] = freq.getCount(i);
    }

    /*
     * Use ChiSquare dist with df = 4-1 = 3, alpha = .001 Change to 11.34
     * for alpha = .01
     */
    assertTrue("chi-square test -- will fail about 1 in 1000 times",
            testStatistic.chiSquare(expected, observed) < 16.27);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:28,代码来源:RandomDataTest.java

示例14: testNextSecureLong

import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
/** test dispersion and failure modes for nextSecureLong() */
public void testNextSecureLong() {
	try {
		randomData.nextSecureLong(4, 3);
		fail("IllegalArgumentException expected");
	} catch (IllegalArgumentException ex) {
		// ignored
	}
	Frequency freq = new Frequency();
	long value = 0;
	for (int i = 0; i < smallSampleSize; i++) {
		value = randomData.nextSecureLong(0, 3);
		assertTrue("nextInt range", (value >= 0) && (value <= 3));
		freq.addValue(value);
	}
	long[] observed = new long[4];
	for (int i = 0; i < 4; i++) {
		observed[i] = freq.getCount(i);
	}

	/*
	 * Use ChiSquare dist with df = 4-1 = 3, alpha = .001 Change to 11.34
	 * for alpha = .01
	 */
	assertTrue("chi-square test -- will fail about 1 in 1000 times",
			testStatistic.chiSquare(expected, observed) < 16.27);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:28,代码来源:RandomDataTest.java

示例15: testNextLong

import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
/** test dispersion and failure modes for nextLong() */
public void testNextLong() {
    try {
        randomData.nextLong(4, 3);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException ex) {
        // ignored
    }
    Frequency freq = new Frequency();
    long value = 0;
    for (int i = 0; i < smallSampleSize; i++) {
        value = randomData.nextLong(0, 3);
        assertTrue("nextInt range", (value >= 0) && (value <= 3));
        freq.addValue(value);
    }
    long[] observed = new long[4];
    for (int i = 0; i < 4; i++) {
        observed[i] = freq.getCount(i);
    }

    /*
     * Use ChiSquare dist with df = 4-1 = 3, alpha = .001 Change to 11.34
     * for alpha = .01
     */
    assertTrue("chi-square test -- will fail about 1 in 1000 times",
            testStatistic.chiSquare(expected, observed) < 16.27);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:28,代码来源:RandomDataTest.java


注:本文中的org.apache.commons.math.stat.Frequency.getCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。