當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。