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


Java SummaryStatistics.newInstance方法代码示例

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


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

示例1: testTwoSampleTHomoscedastic

import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
public void testTwoSampleTHomoscedastic() throws Exception {
    double[] sample1 ={2, 4, 6, 8, 10, 97};
    double[] sample2 = {4, 6, 8, 10, 16};
    SummaryStatistics sampleStats1 = SummaryStatistics.newInstance();  
    for (int i = 0; i < sample1.length; i++) {
        sampleStats1.addValue(sample1[i]);
    }
    SummaryStatistics sampleStats2 = SummaryStatistics.newInstance();    
    for (int i = 0; i < sample2.length; i++) {
        sampleStats2.addValue(sample2[i]);
    }
    
    // Target comparison values computed using R version 1.8.1 (Linux version)
    assertEquals("two sample homoscedastic t stat", 0.73096310086, 
            TestUtils.homoscedasticT(sample1, sample2), 10E-11);
    assertEquals("two sample homoscedastic p value", 0.4833963785, 
            TestUtils.homoscedasticTTest(sampleStats1, sampleStats2), 1E-10);     
    assertTrue("two sample homoscedastic t-test reject", 
            TestUtils.homoscedasticTTest(sample1, sample2, 0.49));
    assertTrue("two sample homoscedastic t-test accept", 
            !TestUtils.homoscedasticTTest(sample1, sample2, 0.48));
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:23,代码来源:TestUtilsTest.java

示例2: testTwoSampleTHomoscedastic

import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
public void testTwoSampleTHomoscedastic() throws Exception {
    double[] sample1 ={2, 4, 6, 8, 10, 97};
    double[] sample2 = {4, 6, 8, 10, 16};
    SummaryStatistics sampleStats1 = SummaryStatistics.newInstance();  
    for (int i = 0; i < sample1.length; i++) {
        sampleStats1.addValue(sample1[i]);
    }
    SummaryStatistics sampleStats2 = SummaryStatistics.newInstance();    
    for (int i = 0; i < sample2.length; i++) {
        sampleStats2.addValue(sample2[i]);
    }
    
    // Target comparison values computed using R version 1.8.1 (Linux version)
    assertEquals("two sample homoscedastic t stat", 0.73096310086, 
          testStatistic.homoscedasticT(sample1, sample2), 10E-11);
    assertEquals("two sample homoscedastic p value", 0.4833963785, 
            testStatistic.homoscedasticTTest(sampleStats1, sampleStats2), 1E-10);     
    assertTrue("two sample homoscedastic t-test reject", 
            testStatistic.homoscedasticTTest(sample1, sample2, 0.49));
    assertTrue("two sample homoscedastic t-test accept", 
            !testStatistic.homoscedasticTTest(sample1, sample2, 0.48));
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:23,代码来源:TTestTest.java

示例3: testUnivariateImpl

import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
/**
 * Test StorelessDescriptiveStatistics
*/
public void testUnivariateImpl() throws Exception {
    SummaryStatistics u = SummaryStatistics.newInstance(SummaryStatisticsImpl.class);
    loadStats("data/PiDigits.txt", u);
    assertEquals("PiDigits: std", std, u.getStandardDeviation(), .0000000000001);
    assertEquals("PiDigits: mean", mean, u.getMean(), .0000000000001);  

    loadStats("data/Mavro.txt", u);
    assertEquals("Mavro: std", std, u.getStandardDeviation(), .00000000000001);
    assertEquals("Mavro: mean", mean, u.getMean(), .00000000000001);
    
    //loadStats("data/Michelso.txt");
    //assertEquals("Michelso: std", std, u.getStandardDeviation(), .00000000000001);
    //assertEquals("Michelso: mean", mean, u.getMean(), .00000000000001);   
                                    
    loadStats("data/NumAcc1.txt", u);
    assertEquals("NumAcc1: std", std, u.getStandardDeviation(), .00000000000001);
    assertEquals("NumAcc1: mean", mean, u.getMean(), .00000000000001);
    
    //loadStats("data/NumAcc2.txt");
    //assertEquals("NumAcc2: std", std, u.getStandardDeviation(), .000000001);
    //assertEquals("NumAcc2: mean", mean, u.getMean(), .00000000000001);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:26,代码来源:CertifiedDataTest.java

示例4: testNextGaussian

import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
/** test failure modes and distribution of nextGaussian() */  
public void testNextGaussian() { 
    try {
        double x = randomData.nextGaussian(0,0);
        fail("zero sigma -- IllegalArgumentException expected");
    } catch (IllegalArgumentException ex) {
        ;
    }
    SummaryStatistics u = SummaryStatistics.newInstance();
    for (int i = 0; i<largeSampleSize; i++) {
        u.addValue(randomData.nextGaussian(0,1));
    }
    double xbar = u.getMean();
    double s = u.getStandardDeviation();
    double n = (double) u.getN(); 
    /* t-test at .001-level TODO: replace with externalized t-test, with
     * test statistic defined in TestStatistic
     */
    assertTrue(Math.abs(xbar)/(s/Math.sqrt(n))< 3.29);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:21,代码来源:RandomDataTest.java

示例5: computeStats

import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
/**
 * Computes sampleStats
 * 
 * @throws IOException if an IOError occurs
 */
public void computeStats() throws IOException {
    String str = null;
    double val = 0.0;
    sampleStats = SummaryStatistics.newInstance();
    while ((str = inputStream.readLine()) != null) {
        val = new Double(str).doubleValue();
        sampleStats.addValue(val);
    }
    inputStream.close();
    inputStream = null;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:17,代码来源:EmpiricalDistributionImpl.java

示例6: setUp

import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
protected void setUp() throws Exception {
    descriptives = DescriptiveStatistics.newInstance();
    summaries = SummaryStatistics.newInstance();
    certifiedValues = new HashMap();
    
    loadData();
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:8,代码来源:CertifiedDataAbstractTest.java

示例7: testNextDigest

import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
/** 
  * Generate 1000 random values and make sure they look OK.<br>
  * Note that there is a non-zero (but very small) probability that
  * these tests will fail even if the code is working as designed.
  */
public void testNextDigest() throws Exception{
    double next = 0.0;
    double tolerance = 0.1;
    vs.computeDistribution();
    assertTrue("empirical distribution property", 
        vs.getEmpiricalDistribution() != null);
    SummaryStatistics stats = SummaryStatistics.newInstance();
    for (int i = 1; i < 1000; i++) {
        next = vs.getNext();
        stats.addValue(next);
    }    
    assertEquals("mean", 5.069831575018909, stats.getMean(), tolerance);
    assertEquals
     ("std dev", 1.0173699343977738, stats.getStandardDeviation(), 
        tolerance);
    
    vs.computeDistribution(500);
    stats = SummaryStatistics.newInstance();
    for (int i = 1; i < 1000; i++) {
        next = vs.getNext();
        stats.addValue(next);
    }    
    assertEquals("mean", 5.069831575018909, stats.getMean(), tolerance);
    assertEquals
     ("std dev", 1.0173699343977738, stats.getStandardDeviation(), 
        tolerance);
    
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:34,代码来源:ValueServerTest.java

示例8: tstGen

import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
private void tstGen(double tolerance)throws Exception {
    empiricalDistribution.load(url);   
    SummaryStatistics stats = SummaryStatistics.newInstance();
    for (int i = 1; i < 1000; i++) {
        stats.addValue(empiricalDistribution.getNextValue());
    }
    assertEquals("mean", stats.getMean(),5.069831575018909,tolerance);
    assertEquals
     ("std dev", stats.getStandardDeviation(),1.0173699343977738,tolerance);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:11,代码来源:EmpiricalDistributionTest.java

示例9: tstDoubleGen

import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
private void tstDoubleGen(double tolerance)throws Exception {
    empiricalDistribution2.load(dataArray);   
    SummaryStatistics stats = SummaryStatistics.newInstance();
    for (int i = 1; i < 1000; i++) {
        stats.addValue(empiricalDistribution2.getNextValue());
    }
    assertEquals("mean", stats.getMean(),5.069831575018909,tolerance);
    assertEquals
     ("std dev", stats.getStandardDeviation(),1.0173699343977738,tolerance);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:11,代码来源:EmpiricalDistributionTest.java

示例10: fillBinStats

import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
/**
 * Fills binStats array (second pass through data file).
 * 
 * @param in object providing access to the data
 * @throws IOException  if an IO error occurs
 */
private void fillBinStats(Object in) throws IOException {
    // Load array of bin upper bounds -- evenly spaced from min - max
    double min = sampleStats.getMin();
    double max = sampleStats.getMax();
    double delta = (max - min)/(new Double(binCount)).doubleValue();
    double[] binUpperBounds = new double[binCount];
    binUpperBounds[0] = min + delta;
    for (int i = 1; i< binCount - 1; i++) {
        binUpperBounds[i] = binUpperBounds[i-1] + delta;
    }
    binUpperBounds[binCount -1] = max;

    // Initialize binStats ArrayList
    if (!binStats.isEmpty()) {
        binStats.clear();
    }
    for (int i = 0; i < binCount; i++) {
        SummaryStatistics stats = SummaryStatistics.newInstance();
        binStats.add(i,stats);
    }

    // Filling data in binStats Array
    DataAdapterFactory aFactory = new DataAdapterFactory();
    DataAdapter da = aFactory.getAdapter(in);
    try {
        da.computeBinStats(min, delta);
    } catch (Exception e) {
        if(e instanceof RuntimeException){
            throw new RuntimeException(e.getMessage());
        }else{
            throw new IOException(e.getMessage());
        }
    }

    // Assign upperBounds based on bin counts
    upperBounds = new double[binCount];
    upperBounds[0] =
    ((double)((SummaryStatistics)binStats.get(0)).getN())/
    (double)sampleStats.getN();
    for (int i = 1; i < binCount-1; i++) {
        upperBounds[i] = upperBounds[i-1] +
        ((double)((SummaryStatistics)binStats.get(i)).getN())/
        (double)sampleStats.getN();
    }
    upperBounds[binCount-1] = 1.0d;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:53,代码来源:EmpiricalDistributionImpl.java

示例11: setUp

import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
public void setUp() {
    tooShortStats = SummaryStatistics.newInstance();
    tooShortStats.addValue(0d);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:5,代码来源:TTestTest.java


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