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


Java SummaryStatistics.clear方法代码示例

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


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

示例1: populateStatistics

import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
/**
 * Handles the process of injecting data into the summary statistics class for calculation.
 *
 * @param summaryStatistics The summary statistics object
 * @param someData The data set to calculate statistics with
 * @return The summary statistics object
 */
private SummaryStatistics populateStatistics(SummaryStatistics summaryStatistics, List<Data> someData)
{
    summaryStatistics.clear();
    for (Data someDatum : someData)
    {
        summaryStatistics.addValue(someDatum.getTemperature());
    }
    return summaryStatistics;
}
 
开发者ID:MTUHIDE,项目名称:CoCoTemp,代码行数:17,代码来源:SiteStatisticsServiceImplementation.java

示例2: noisySeasonalTest

import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
@Test
public void noisySeasonalTest() {
	long seed = 1234567L; // System.nanoTime() // change this to do random stress test
	int numAverages = 1; // Increase to tighten the statistics on the sample statistics
	int trials = 100;
	double start = 1.5;
	double delta = 0.0;

	SummaryStatistics seasonalZScoreStats = new SummaryStatistics();
	SummaryStatistics varianceFractionStats = new SummaryStatistics();

	SummaryStatistics fractionClassifiedStats = new SummaryStatistics();
	SummaryStatistics sampleZScoreStats = new SummaryStatistics();
	SummaryStatistics sampleVarFracStats = new SummaryStatistics();

	for (int j = 0; j < numAverages; ++j) {
		int count = 0;
		double seasonalAmplitude = start + delta * j;
		double noiseSigma = 3.0;

		for (int i = 0; i < trials; ++i) {

			double[] data = testDataGenerator.createNoisySeasonalData(
					168 * 4, 168, seasonalAmplitude, 0.0, noiseSigma, seed++);

			Decomposition stl = SeasonalTrendLoess.performRobustPeriodicDecomposition(data, 168);

			StlFitStats stats = new StlFitStats(stl);

			assertTrue(stats.getTrendinessZScore() < 3.0);

			stl.smoothSeasonal(15);
			StlFitStats smoothedStats = new StlFitStats(stl);

			double vf = smoothedStats.getSeasonalVariance() / smoothedStats.getResidualVariance();
			varianceFractionStats.addValue(vf);

			double z = smoothedStats.getSeasonalZScore();
			seasonalZScoreStats.addValue(z);

			if (z > 3.0)
				++count;
		}

		double rate = ((double) count) / trials;

		fractionClassifiedStats.addValue(rate);

		sampleZScoreStats.addValue(seasonalZScoreStats.getMean());
		sampleVarFracStats.addValue(varianceFractionStats.getMean());

		seasonalZScoreStats.clear();
		varianceFractionStats.clear();
	}

	assertTrue("Min Average Z-Score", sampleZScoreStats.getMin() > 3.13);
	assertTrue("Avg Average Z-Score", Math.abs(sampleZScoreStats.getMean() - 3.64) < 0.06);
	assertTrue("Max Average Z-Score", sampleZScoreStats.getMax() < 4.13);

	assertTrue("Min Var Frac", sampleVarFracStats.getMin() > 0.173);
	assertTrue("Avg Var Frac", Math.abs(sampleVarFracStats.getMean() - 0.193) < 0.01);
	assertTrue("Max Var Frac", sampleVarFracStats.getMax() < 0.213);
}
 
开发者ID:ServiceNow,项目名称:stl-decomp-4j,代码行数:64,代码来源:StlFitStatsTest.java


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