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


Java SummaryStatistics.getN方法代码示例

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


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

示例1: getNextValue

import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
/**
 * Generates a random value from this distribution.
 * 
 * @return the random value.
 * @throws IllegalStateException if the distribution has not been loaded
 */
public double getNextValue() throws IllegalStateException {

    if (!loaded) {
        throw new IllegalStateException("distribution not loaded");
    }

    // Start with a uniformly distributed random number in (0,1)
    double x = Math.random();

    // Use this to select the bin and generate a Gaussian within the bin
    for (int i = 0; i < binCount; i++) {
       if (x <= upperBounds[i]) {
           SummaryStatistics stats = (SummaryStatistics)binStats.get(i);
           if (stats.getN() > 0) {
               if (stats.getStandardDeviation() > 0) {  // more than one obs
                    return randomData.nextGaussian
                        (stats.getMean(),stats.getStandardDeviation());
               } else {
                   return stats.getMean(); // only one obs in bin
               }
           }
       }
    }
    throw new RuntimeException("No bin selected");
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:32,代码来源:EmpiricalDistributionImpl.java

示例2: testNextGaussian

import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
/** test failure modes and distribution of nextGaussian() */  
public void testNextGaussian() { 
    try {
        randomData.nextGaussian(0,0);
        fail("zero sigma -- IllegalArgumentException expected");
    } catch (IllegalArgumentException ex) {
        ;
    }
    SummaryStatistics u = new SummaryStatistics();
    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:cacheonix,项目名称:cacheonix-core,代码行数:21,代码来源:RandomDataTest.java

示例3: testNextGaussian

import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
/** test failure modes and distribution of nextGaussian() */
public void testNextGaussian() {
    try {
        randomData.nextGaussian(0, 0);
        fail("zero sigma -- IllegalArgumentException expected");
    } catch (IllegalArgumentException ex) {
        // ignored
    }
    SummaryStatistics u = new SummaryStatistics();
    for (int i = 0; i < largeSampleSize; i++) {
        u.addValue(randomData.nextGaussian(0, 1));
    }
    double xbar = u.getMean();
    double s = u.getStandardDeviation();
    double n = 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,代码行数:22,代码来源:RandomDataTest.java

示例4: getNextValue

import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
/**
 * Generates a random value from this distribution.
 *
 * @return the random value.
 * @throws IllegalStateException if the distribution has not been loaded
 */
public double getNextValue() throws IllegalStateException {

    if (!loaded) {
        throw MathRuntimeException.createIllegalStateException(LocalizedFormats.DISTRIBUTION_NOT_LOADED);
    }

    // Start with a uniformly distributed random number in (0,1)
    double x = FastMath.random();

    // Use this to select the bin and generate a Gaussian within the bin
    for (int i = 0; i < binCount; i++) {
       if (x <= upperBounds[i]) {
           SummaryStatistics stats = binStats.get(i);
           if (stats.getN() > 0) {
               if (stats.getStandardDeviation() > 0) {  // more than one obs
                    return randomData.nextGaussian
                        (stats.getMean(),stats.getStandardDeviation());
               } else {
                   return stats.getMean(); // only one obs in bin
               }
           }
       }
    }
    throw new MathRuntimeException(LocalizedFormats.NO_BIN_SELECTED);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:32,代码来源:EmpiricalDistributionImpl.java

示例5: testNextGaussian

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

示例6: getNextValue

import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
/**
 * Generates a random value from this distribution.
 *
 * @return the random value.
 * @throws IllegalStateException if the distribution has not been loaded
 */
public double getNextValue() throws IllegalStateException {

    if (!loaded) {
        throw MathRuntimeException.createIllegalStateException(LocalizedFormats.DISTRIBUTION_NOT_LOADED);
    }

    // Start with a uniformly distributed random number in (0,1)
    double x = randomData.nextUniform(0,1);

    // Use this to select the bin and generate a Gaussian within the bin
    for (int i = 0; i < binCount; i++) {
       if (x <= upperBounds[i]) {
           SummaryStatistics stats = binStats.get(i);
           if (stats.getN() > 0) {
               if (stats.getStandardDeviation() > 0) {  // more than one obs
                    return randomData.nextGaussian
                        (stats.getMean(),stats.getStandardDeviation());
               } else {
                   return stats.getMean(); // only one obs in bin
               }
           }
       }
    }
    throw new MathRuntimeException(LocalizedFormats.NO_BIN_SELECTED);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:32,代码来源:EmpiricalDistributionImpl.java

示例7: testNextGaussian

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

示例8: getNextValue

import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
/**
 * Generates a random value from this distribution.
 *
 * @return the random value.
 * @throws IllegalStateException if the distribution has not been loaded
 */
public double getNextValue() throws IllegalStateException {

    if (!loaded) {
        throw MathRuntimeException.createIllegalStateException("distribution not loaded");
    }

    // Start with a uniformly distributed random number in (0,1)
    double x = Math.random();

    // Use this to select the bin and generate a Gaussian within the bin
    for (int i = 0; i < binCount; i++) {
       if (x <= upperBounds[i]) {
           SummaryStatistics stats = binStats.get(i);
           if (stats.getN() > 0) {
               if (stats.getStandardDeviation() > 0) {  // more than one obs
                    return randomData.nextGaussian
                        (stats.getMean(),stats.getStandardDeviation());
               } else {
                   return stats.getMean(); // only one obs in bin
               }
           }
       }
    }
    throw new MathRuntimeException("no bin selected");
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:32,代码来源:EmpiricalDistributionImpl.java

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

示例10: testNextGaussian

import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
/** test failure modes and distribution of nextGaussian() */
public void testNextGaussian() {
	try {
		randomData.nextGaussian(0, 0);
		fail("zero sigma -- IllegalArgumentException expected");
	} catch (IllegalArgumentException ex) {
		// ignored
	}
	SummaryStatistics u = new SummaryStatistics();
	for (int i = 0; i < largeSampleSize; i++) {
		u.addValue(randomData.nextGaussian(0, 1));
	}
	double xbar = u.getMean();
	double s = u.getStandardDeviation();
	double n = 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,代码行数:22,代码来源:RandomDataTest.java

示例11: getNextValue

import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
/**
 * Generates a random value from this distribution.
 * 
 * @return the random value.
 * @throws IllegalStateException if the distribution has not been loaded
 */
public double getNextValue() throws IllegalStateException {

    if (!loaded) {
        throw MathRuntimeException.createIllegalStateException("distribution not loaded");
    }

    // Start with a uniformly distributed random number in (0,1)
    double x = Math.random();

    // Use this to select the bin and generate a Gaussian within the bin
    for (int i = 0; i < binCount; i++) {
       if (x <= upperBounds[i]) {
           SummaryStatistics stats = binStats.get(i);
           if (stats.getN() > 0) {
               if (stats.getStandardDeviation() > 0) {  // more than one obs
                    return randomData.nextGaussian
                        (stats.getMean(),stats.getStandardDeviation());
               } else {
                   return stats.getMean(); // only one obs in bin
               }
           }
       }
    }
    throw new MathRuntimeException("no bin selected");
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:32,代码来源:EmpiricalDistributionImpl.java

示例12: asStatisticalData

import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
public static StatisticalData asStatisticalData(SummaryStatistics value){
	StatisticalData d = CommonFactory.eINSTANCE.createStatisticalData();

	long samples = value.getN();
	d.setSamples(samples);

	if (samples > 0) {
		d.setMean(value.getMean());
		d.setMin(value.getMin());
		d.setMax(value.getMax());
		d.setVariance(value.getVariance());
		d.setGeometricMean(value.getGeometricMean());
		d.setSum(value.getSum());
		d.setSumOfLogs(value.getSumOfLogs());
		d.setSumOfSquares(value.getSumsq());
		d.setStandardDeviation(value.getStandardDeviation());
		d.setSecondMoment(value.getSecondMoment());
	} else {
		d.setMean(0);
		d.setMin(0);
		d.setMax(0);
		d.setVariance(0);
		d.setGeometricMean(0);
		d.setSum(0);
		d.setSumOfLogs(0);
		d.setSumOfSquares(0);
		d.setStandardDeviation(0);
		d.setSecondMoment(0);
	}

	return d;
}
 
开发者ID:turnus,项目名称:turnus,代码行数:33,代码来源:StatisticalData.java

示例13: format

import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
/**
 * Pretty print a time
 * @param ss the stats defining the time
 * @return a string representing the time
 */
public static String format(SummaryStatistics ss) {
	if (ss.getN() == 1) {
		return formatTime(ss.getMean());
	} 
	return formatTime(ss.getMean(), ss.getStandardDeviation());
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:12,代码来源:TimeTracker.java

示例14: getValueFromSummaryStatistics

import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
double getValueFromSummaryStatistics(SummaryStatistics summaryStatistics) {
	return summaryStatistics.getN()==0 ? 0 : summaryStatistics.getStandardDeviation();
}
 
开发者ID:barelas,项目名称:gemu,代码行数:4,代码来源:UserQoSStandardDeviationStatsAggregator.java


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