• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Frequency类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Frequency类属于org.apache.commons.math.stat包,在下文中一共展示了Frequency类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: computeStatistics

import org.apache.commons.math.stat.Frequency; //导入依赖的package包/类
private static void computeStatistics(List<StandaloneArgument> annotatedArguments,
        int skippedArgumentsFromMACE)
{
    Frequency frequency = new Frequency();
    for (int i = 0; i < skippedArgumentsFromMACE; i++) {
        frequency.addValue("Skipped from MACE");
    }

    for (StandaloneArgument argument : annotatedArguments) {
        String annotatedStance = argument.getAnnotatedStance();

        if (annotatedStance != null) {
            int intValue = argument.getMappingAllStancesToInt().get(annotatedStance);
            // 0 and 1 treat as one stance (pro/con doesn't matter here)
            if (intValue == 1) {
                intValue = 0;
            }

            frequency.addValue(String.valueOf(intValue) + (argument.isAnnotatedSarcastic() ?
                    "_sarc" :
                    ""));
        }
        else {
            frequency.addValue("No stance");
        }
    }

    System.out.println(frequency);
}
 
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:30,代码来源:Step1bGoldStanceAnnotator.java


示例17: main

import org.apache.commons.math.stat.Frequency; //导入依赖的package包/类
public static void main(String[] args)
        throws IOException
{
    File inputFile = new File(
            "mturk/annotation-task/data/32-reasons-batch-0001-5000-2026args-gold.xml.gz");

    // read all arguments from the original corpus
    List<StandaloneArgument> arguments = XStreamSerializer
            .deserializeArgumentListFromXML(inputFile);
    System.out.println("Arguments: " + arguments.size());

    Frequency frequency = new Frequency();
    DescriptiveStatistics statistics = new DescriptiveStatistics();

    for (StandaloneArgument argument : arguments) {
        JCas jCas = argument.getJCas();
        Collection<Premise> premises = JCasUtil.select(jCas, Premise.class);

        frequency.addValue(premises.size());
        statistics.addValue(premises.size());
    }

    System.out.println(frequency);
    System.out.println(statistics.getSum());
    System.out.println(statistics.getMean());
    System.out.println(statistics.getStandardDeviation());
}
 
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:28,代码来源:Step2dGoldReasonStatistics.java


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


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


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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java XSDVocabulary类代码示例发布时间:2022-05-22
下一篇:
Java DescribeParameter类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap