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


Java Frequency类代码示例

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


Frequency类属于org.apache.commons.math.stat包,在下文中一共展示了Frequency类的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包/类
@Override
public void testNextInt() {
    try {
        testGenerator.nextInt(-1);
        fail("MathIllegalArgumentException expected");
    } catch (MathIllegalArgumentException 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

示例9: 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

示例10: 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

示例11: 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

示例12: testNextSecureLong

import org.apache.commons.math.stat.Frequency; //导入依赖的package包/类
/** test dispersion and failure modes for nextSecureLong() */
public void testNextSecureLong() {
    try {
        long x = 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:SpoonLabs,项目名称:astor,代码行数:27,代码来源:RandomDataTest.java

示例13: 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

示例14: testNextInt

import org.apache.commons.math.stat.Frequency; //导入依赖的package包/类
public void testNextInt() {
    try {
        int x = 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:SpoonLabs,项目名称:astor,代码行数:26,代码来源:AbstractRandomGeneratorTest.java

示例15: export

import org.apache.commons.math.stat.Frequency; //导入依赖的package包/类
private static void export(File argumentsWithReasonsFile, File argumentsWithGistFile,
        File outputDir)
        throws Exception
{
    List<StandaloneArgument> arguments = ExportHelper.copyReasonAnnotationsWithGistOnly(
            argumentsWithReasonsFile, argumentsWithGistFile);

    String metaDataCSV = ExportHelper.exportMetaDataToCSV(arguments);
    FileUtils.write(new File(outputDir, "metadata.csv"), metaDataCSV, "utf-8");

    Frequency premisesFrequency = new Frequency();
    DescriptiveStatistics premisesStatistics = new DescriptiveStatistics();

    // and export them all as XMI files using standard DKPro pipeline
    for (StandaloneArgument argument : arguments) {
        JCas jCas = argument.getJCas();
        SimplePipeline.runPipeline(jCas, AnalysisEngineFactory.createEngineDescription(
                XmiWriter.class,
                XmiWriter.PARAM_TARGET_LOCATION, outputDir,
                XmiWriter.PARAM_USE_DOCUMENT_ID, true,
                XmiWriter.PARAM_OVERWRITE, true
        ));

        // count all premises
        int count = JCasUtil.select(jCas, Premise.class).size();
        premisesStatistics.addValue(count);
        premisesFrequency.addValue(count);
    }

    System.out.println("Premises total: " + premisesStatistics.getSum());
    System.out.println("Argument: " + arguments.size());
    System.out.println(premisesFrequency);
}
 
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:34,代码来源:Step3dExportGistToXMIFiles.java


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