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


Java SummaryStatistics.addValue方法代码示例

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


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

示例1: getAggregateStats

import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
public void getAggregateStats(double[] values1, double[] values2){
	AggregateSummaryStatistics aggregate = new AggregateSummaryStatistics();
	SummaryStatistics firstSet = aggregate.createContributingStatistics();
	SummaryStatistics secondSet = aggregate.createContributingStatistics();
	
	for(int i = 0; i < values1.length; i++) {
		firstSet.addValue(values1[i]);
	}
	for(int i = 0; i < values2.length; i++) {
		secondSet.addValue(values2[i]);
	}
	
	double sampleSum = aggregate.getSum();
	double sampleMean = aggregate.getMean();
	double sampleStd= aggregate.getStandardDeviation();
	System.out.println(sampleSum + "\t" + sampleMean + "\t" + sampleStd);
}
 
开发者ID:PacktPublishing,项目名称:Java-Data-Science-Cookbook,代码行数:18,代码来源:AggregateStats.java

示例2: getEdges

import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
private static FloatVector getEdges(MultiImage img) {
  SummaryStatistics[] stats = new SummaryStatistics[256];
  for (int i = 0; i < 256; ++i) {
    stats[i] = new SummaryStatistics();
  }
  List<Boolean> edgePixels = EdgeImg.getEdgePixels(img,
      new ArrayList<Boolean>(img.getWidth() * img.getHeight()));
  ArrayList<LinkedList<Boolean>> partition = GridPartitioner.partition(edgePixels, img.getWidth(),
      img.getHeight(), 16, 16);
  for (int i = 0; i < partition.size(); ++i) {
    LinkedList<Boolean> edge = partition.get(i);
    SummaryStatistics stat = stats[i];
    for (boolean b : edge) {
      stat.addValue(b ? 1 : 0);
    }
  }
  float[] f = new float[256];
  for (int i = 0; i < 256; ++i) {
    f[i] = (float) stats[i].getMean();
  }

  return new FloatVectorImpl(f);
}
 
开发者ID:vitrivr,项目名称:cineast,代码行数:24,代码来源:EdgeGrid16Full.java

示例3: getEdges

import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
private static FloatVector getEdges(MultiImage img) {
  SummaryStatistics[] stats = new SummaryStatistics[64];
  for (int i = 0; i < 64; ++i) {
    stats[i] = new SummaryStatistics();
  }
  List<Boolean> edgePixels = EdgeImg.getEdgePixels(img,
      new ArrayList<Boolean>(img.getWidth() * img.getHeight()));
  ArrayList<LinkedList<Boolean>> partition = ARPartioner.partition(edgePixels, img.getWidth(),
      img.getHeight(), 8, 8);
  for (int i = 0; i < partition.size(); ++i) {
    LinkedList<Boolean> edge = partition.get(i);
    SummaryStatistics stat = stats[i];
    for (boolean b : edge) {
      stat.addValue(b ? 1 : 0);
    }
  }
  float[] f = new float[64];
  for (int i = 0; i < 64; ++i) {
    f[i] = (float) stats[i].getMean();
  }

  return new FloatVectorImpl(f);
}
 
开发者ID:vitrivr,项目名称:cineast,代码行数:24,代码来源:EdgeARP88.java

示例4: getFeatures

import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
/**
 * Returns a list of feature vectors given a SegmentContainer.
 *
 * @param segment SegmentContainer for which to calculate the feature vectors.
 * @return List of HPCP Shingle feature vectors.
 */
private List<float[]> getFeatures(SegmentContainer segment) {
    /* Create STFT; If this fails, return empty list. */
    Pair<Integer,Integer> parameters = FFTUtil.parametersForDuration(segment.getSamplingrate(), WINDOW_SIZE);
    STFT stft = segment.getSTFT(parameters.first,(parameters.first - 2*parameters.second)/2, parameters.second, new HanningWindow());
    if (stft == null) {
      return new ArrayList<>();
    }

    HPCP hpcps = new HPCP(this.resolution, this.min_frequency, this.max_frequency);
    hpcps.addContribution(stft);

    int vectors = Math.max(hpcps.size() - SHINGLE_SIZE, 1);
    final SummaryStatistics statistics = new SummaryStatistics();

    List<Pair<Double, float[]>> features = new ArrayList<>(vectors);
    for (int n = 0; n < vectors; n++) {
        Pair<Double, float[]> feature = this.getHPCPShingle(hpcps, n);
        features.add(feature);
        statistics.addValue(feature.first);
    }

    final double threshold = 0.25*statistics.getGeometricMean();
    return features.stream().filter(f -> (f.first > threshold)).map(f -> f.second).collect(Collectors.toList());
}
 
开发者ID:vitrivr,项目名称:cineast,代码行数:31,代码来源:HPCPShingle.java

示例5: calcClusterMeanInfo

import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
private double calcClusterMeanInfo(Set<Integer> members) throws AdeInternalException {
    if (members.size() == 1){
        return 0;
    }
    final SummaryStatistics sumS = new SummaryStatistics();
    for (int i : members){
        for (int j : members) {
            if (i <= j){
                continue;
            }
            double v;
            v = m_informationMat.get(i, j);
            if (!Double.isNaN(v)){
                sumS.addValue(v);
            }
        }
    }
    final double res = sumS.getMean();
    if (Double.isNaN(res)){
        return 0;
    }
    return res;

}
 
开发者ID:openmainframeproject,项目名称:ade,代码行数:25,代码来源:AbstractClusteringScorer.java

示例6: anovaStats

import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
/**
 * This method calls the method that actually does the calculations (except
 * P-value).
 *
 * @param categoryData
 *            <code>Collection</code> of <code>double[]</code> arrays each
 *            containing data for one category
 * @return computed AnovaStats
 * @throws NullArgumentException
 *             if <code>categoryData</code> is <code>null</code>
 * @throws DimensionMismatchException
 *             if the length of the <code>categoryData</code> array is less
 *             than 2 or a contained <code>double[]</code> array does not
 *             contain at least two values
 */
private AnovaStats anovaStats(final Collection<double[]> categoryData)
    throws NullArgumentException, DimensionMismatchException {

    MathUtils.checkNotNull(categoryData);

    final Collection<SummaryStatistics> categoryDataSummaryStatistics =
            new ArrayList<SummaryStatistics>(categoryData.size());

    // convert arrays to SummaryStatistics
    for (final double[] data : categoryData) {
        final SummaryStatistics dataSummaryStatistics = new SummaryStatistics();
        categoryDataSummaryStatistics.add(dataSummaryStatistics);
        for (final double val : data) {
            dataSummaryStatistics.addValue(val);
        }
    }

    return anovaStats(categoryDataSummaryStatistics, false);

}
 
开发者ID:biocompibens,项目名称:SME,代码行数:36,代码来源:OneWayAnova.java

示例7: getSummaryStatisticsForCollection

import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
/**
 * This function will take an aggregated collection of Summary Statistics
 * and will generate a derived {@link SummaryStatistic} based on a flag for the  
 * desired summation.  This is particularly helpful for finding out the
 * means of the individual statistics of the collection.
 * For example, if you wanted to find out the mean of means of the collection
 * you would call this function like <p>
 * getSummaryStatisticsForCollection(aggregate,1).getMean(); <p>
 * Or if you wanted to determine the max number of annotations per
 * individual, you could call: <p>
 * getSummaryStatisticsForCollection(aggregate,5).getMax(); <p>
 * The stat flag should be set to the particular individual statistic that should
 * be summarized over.
 *
 * @param aggregate The aggregated collection of summary statistics
 * @param stat  Integer flag for the statistic (1:mean ; 2:sum; 3:min; 4:max; 5:N)
 * @return {@link SummaryStatistics} of the selected statistic
 */
public SummaryStatistics getSummaryStatisticsForCollection(Collection<SummaryStatistics> aggregate, Stat stat) {
	//LOG.info("Computing stats over collection of "+aggregate.size()+" elements ("+stat+"):");
	//TODO: turn stat into enum
	int x = 0;
	//To save memory, I am using SummaryStatistics, which does not store the values,
	//but this could be changed to DescriptiveStatistics to see values
	//as well as other statistical functions like distributions
	SummaryStatistics stats = new SummaryStatistics();
	Double v = 0.0;
	ArrayList<String> vals = new ArrayList();
	for (SummaryStatistics s : aggregate) {
		switch (stat) {
		case MEAN : v= s.getMean(); stats.addValue(s.getMean()); break;
		case SUM : v=s.getSum(); stats.addValue(s.getSum()); break;
		case MIN : v=s.getMin(); stats.addValue(s.getMin()); break;
		case MAX : v=s.getMax(); stats.addValue(s.getMax()); break;
		case N : v= ((int)s.getN())*1.0; stats.addValue(s.getN()); break;
		};
		//vals.add(v.toString());
	};
	//LOG.info("vals: "+vals.toString());
	return stats;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:42,代码来源:AbstractOwlSim.java

示例8: testTwoSampleTHomoscedastic

import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
@Test
public void testTwoSampleTHomoscedastic() {
    double[] sample1 ={2, 4, 6, 8, 10, 97};
    double[] sample2 = {4, 6, 8, 10, 16};
    SummaryStatistics sampleStats1 = new SummaryStatistics();
    for (int i = 0; i < sample1.length; i++) {
        sampleStats1.addValue(sample1[i]);
    }
    SummaryStatistics sampleStats2 = new SummaryStatistics();
    for (int i = 0; i < sample2.length; i++) {
        sampleStats2.addValue(sample2[i]);
    }

    // Target comparison values computed using R version 1.8.1 (Linux version)
    Assert.assertEquals("two sample homoscedastic t stat", 0.73096310086,
          testStatistic.homoscedasticT(sample1, sample2), 10E-11);
    Assert.assertEquals("two sample homoscedastic p value", 0.4833963785,
            testStatistic.homoscedasticTTest(sampleStats1, sampleStats2), 1E-10);
    Assert.assertTrue("two sample homoscedastic t-test reject",
            testStatistic.homoscedasticTTest(sample1, sample2, 0.49));
    Assert.assertTrue("two sample homoscedastic t-test accept",
            !testStatistic.homoscedasticTTest(sample1, sample2, 0.48));
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:24,代码来源:TTestTest.java

示例9: initialiseGaussianDistributionForNumericAttribute

import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
private Map<Attribute, Map<Double, NormalDistribution>> initialiseGaussianDistributionForNumericAttribute(Instance instanceInfo, ArrayList<Instance> instancesList){
	
	Map<Attribute, Map<Double, NormalDistribution>> numericAttributeClassGaussDistributions = new HashMap<>();
	
	// go through each numeric attibute
	for (Attribute attribute : Collections.list(instanceInfo.enumerateAttributes())) {
		
		// check whether the attribute is numeric
		if(attribute.isNumeric()){
			
			// for each class label
			HashMap<Double, NormalDistribution> classLabelDistribution = new HashMap<>();
			for (int classLabelNo = 0; classLabelNo < instanceInfo.numClasses(); classLabelNo++) {
				
				// go through all instance in the dataset to create normal distribution
				SummaryStatistics summaryStatistics = new SummaryStatistics();
				for (Instance instance : instancesList) {
					
					summaryStatistics.addValue(instance.value(attribute));
				}
				
				// create normal distribution for this attribute with corresponding
				// class label
				NormalDistribution normalDistribution = new NormalDistribution(
						summaryStatistics.getMean(), 
						summaryStatistics.getStandardDeviation());
				
				// map to hold classLabel and distribution
				classLabelDistribution.put((double) classLabelNo, normalDistribution);
				
			}
			
			// put it into the map
			numericAttributeClassGaussDistributions.put(attribute, classLabelDistribution);
		}
		
	}
				
	return numericAttributeClassGaussDistributions;
}
 
开发者ID:thienle2401,项目名称:G-eRules,代码行数:41,代码来源:GeRules.java

示例10: getSummaryStats

import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
public void getSummaryStats(double[] values){
	SummaryStatistics stats = new SummaryStatistics();
	for( int i = 0; i < values.length; i++) {
	        stats.addValue(values[i]);
	}
	double mean = stats.getMean();
	double std = stats.getStandardDeviation();
	System.out.println(mean + "\t" + std);
}
 
开发者ID:PacktPublishing,项目名称:Java-Data-Science-Cookbook,代码行数:10,代码来源:SummaryStats.java

示例11: pureSineTest

import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
@Test
public void pureSineTest() {

	long seed = 1234567L; // System.nanoTime() // change this to do random stress test

	double[] data = testDataGenerator.createNoisySeasonalData(144, 12, 1.0, 0.0, 0.0, seed); // sin(2 \pi i / 12)

	final Builder builder = new Builder().setPeriodLength(12).setSeasonalWidth(7).setRobustFlag(false);
	SeasonalTrendLoess smoother = builder.buildSmoother(data);

	Decomposition stl = smoother.decompose();

	StlFitStats stats = new StlFitStats(stl);

	SummaryStatistics dataStats = new SummaryStatistics();
	for (double v : stl.getData())
		dataStats.addValue(v);

	assertEquals("raw data mean", 0.0, stats.getDataMean(), 1.0e-11);
	assertEquals("raw data variance", dataStats.getVariance(), stats.getDataVariance(), 1.0e-11);
	assertEquals("raw data std dev", dataStats.getStandardDeviation(), stats.getDataStdDev(), 1.0e-11);

	assertEquals("trend mean", 0.0, stats.getTrendMean(), 1.0e-11);
	assertEquals("trend range", 0.0, stats.getTrendRange(), 1.0e-11);

	assertEquals("seasonal mean", 0.0, stats.getSeasonalMean(), 1.0e-11);
	assertEquals("seasonal variance", dataStats.getVariance(), stats.getSeasonalVariance(), 1.0e-11);
	assertEquals("seasonal std dev", dataStats.getStandardDeviation(), stats.getSeasonalStdDev(), 1.0e-11);

	assertEquals("residual mean", 0.0, stats.getResidualMean(), 1.0e-11);
	assertEquals("residual variance", 0.0, stats.getResidualVariance(), 1.0e-11);
	assertEquals("residual std dev", 0.0, stats.getResidualStdDev(), 1.0e-11);

	assertEquals("deseasonal mean", 0.0, stats.getDeSeasonalMean(), 1.0e-11);
	assertEquals("deseasonal variance", 0.0, stats.getDeSeasonalVariance(), 1.0e-11);

	assertEquals("trend test z-score", 0.0, stats.getTrendinessZScore(), 1.0e-11);
	assertEquals("seasonal test z-score", stats.getSeasonalVariance(), 1.0e-6 * stats.getSeasonalZScore(), 1.0e-11);
}
 
开发者ID:ServiceNow,项目名称:stl-decomp-4j,代码行数:40,代码来源:StlFitStatsTest.java

示例12: pureTrendTest

import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
@Test
public void pureTrendTest() {

	long seed = 1234567L; // System.nanoTime() // change this to do random stress test

	// linear trend (2 \pi i / 12)
	double[] data = testDataGenerator.createNoisySeasonalData(144, 12, 0.0, 1.0, 0.0, seed);

	final Builder builder = new Builder().setPeriodLength(12).setSeasonalWidth(7).setNonRobust();
	SeasonalTrendLoess smoother = builder.buildSmoother(data);

	Decomposition stl = smoother.decompose();

	StlFitStats stats = new StlFitStats(stl);

	SummaryStatistics dataStats = new SummaryStatistics();
	for (double v : stl.getData())
		dataStats.addValue(v);

	assertEquals("raw data mean", dataStats.getMean(), stats.getDataMean(), 1.0e-11);
	assertEquals("raw data variance", dataStats.getVariance(), stats.getDataVariance(), 1.0e-11);
	assertEquals("raw data std dev", dataStats.getStandardDeviation(), stats.getDataStdDev(), 1.0e-11);

	assertEquals("trend mean", dataStats.getMean(), stats.getTrendMean(), 1.0e-11);
	assertEquals("trend range", 2.0 * dataStats.getMean(), stats.getTrendRange(), 1.0e-11);

	assertEquals("seasonal mean", 0.0, stats.getSeasonalMean(), 1.0e-11);
	assertEquals("seasonal variance", 0.0, stats.getSeasonalVariance(), 1.0e-11);
	assertEquals("seasonal std dev", 0.0, stats.getSeasonalStdDev(), 1.0e-11);

	assertEquals("residual mean", 0.0, stats.getResidualMean(), 1.0e-11);
	assertEquals("residual variance", 0.0, stats.getResidualVariance(), 1.0e-11);
	assertEquals("residual std dev", 0.0, stats.getResidualStdDev(), 1.0e-11);

	assertEquals("deseasonal mean", dataStats.getMean(), stats.getDeSeasonalMean(), 1.0e-11);
	assertEquals("deseasonal variance", dataStats.getVariance(), stats.getDeSeasonalVariance(), 1.0e-11);
	assertEquals("trend test z-score", dataStats.getVariance(), 1.0e-6 * stats.getTrendinessZScore(), 1.0e-11);
	assertEquals("seasonal test z-score", 0.0, 1.0e-6 * stats.getSeasonalZScore(), 1.0e-11);
}
 
开发者ID:ServiceNow,项目名称:stl-decomp-4j,代码行数:40,代码来源:StlFitStatsTest.java

示例13: spectrogramMeanSd

import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
/**
 * @param spectrogram
 * @return double[]{mean, sd}
 */
public static double[] spectrogramMeanSd(List<float[]> spectrogram)
{
	SummaryStatistics stat=new SummaryStatistics();
	for(float[] spec: spectrogram) for(float v: spec) stat.addValue(v);
	return new double[]{stat.getMean(), stat.getStandardDeviation()};
}
 
开发者ID:cycentum,项目名称:birdsong-recognition,代码行数:11,代码来源:SoundUtils.java

示例14: printImpostorThresholds

import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
private void printImpostorThresholds(Set<float[]> impostorScoresArray) {

		// Calculate Distributions - only with raw scores, not imp_prob scores
		if (!isImpProb) {

			SummaryStatistics muStats = new SummaryStatistics();
			SummaryStatistics sigmaStats = new SummaryStatistics();
			SummaryStatistics shapeStats = new SummaryStatistics();

			for (float[] impostorScores : impostorScoresArray) {

				double[] scores = new double[impostorScores.length];
				for (int i = 0; i < impostorScores.length; i++) {
					scores[i] = impostorScores[i];
				}

				GaussianParetoDistribution dist = new GaussianParetoDistribution(scores);
				shapeStats.addValue(dist.getShape());
				muStats.addValue(dist.getMu());
				sigmaStats.addValue(dist.getSigma());
			}

			String type = cmd.get("type");

			if (muStats.getN() < 100) {
				System.out.printf("Warning: result is statistically weak as not enough data recorded: %d < 100%n", muStats.getN());
			}

			// System.out.println("mu_stats:"+muStats);
			// System.out.println("sigma_stats:"+sigmaStats);
			// System.out.println("shape_stats:"+shapeStats);

			System.out.printf("calibration.impostor_mu.print_%s=%.3f%n", type, muStats.getMean());
			System.out.printf("calibration.impostor_sigma.print_%s=%.3f%n", type, sigmaStats.getMean());
			System.out.printf("calibration.impostor_shape.print_%s=%.3f%n", type, shapeStats.getMean());

		}
	}
 
开发者ID:Auraya,项目名称:armorvox-client,代码行数:39,代码来源:ClientHandlerV5.java

示例15: getSubGraphFrom

import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
private SubGraph getSubGraphFrom(Collection<Integer> jSubGraph, int subGraphId) {
  SummaryStatistics summaryStatisticsQ = new SummaryStatistics();
  SummaryStatistics summaryStatisticsArea = new SummaryStatistics();
  List<GraphItem> graphItems = clusteringGraph.getItems();
  for (Integer i : jSubGraph) {
    GraphItem graphItem = graphItems.get(i);
    graphItem.setSubgraphId(subGraphId);
    summaryStatisticsQ.addValue(graphItem.getQ());
    summaryStatisticsArea.addValue(graphItem.getArea());
  }
  return new SubGraph(subGraphId, jSubGraph, summaryStatisticsQ, summaryStatisticsArea);
}
 
开发者ID:Orange-OpenSource,项目名称:documentare-simdoc,代码行数:13,代码来源:SubgraphsBuilder.java


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