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


Java SummaryStatistics.getSum方法代码示例

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


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

示例1: getStats

import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
private static Stats getStats(FloatColumn values, SummaryStatistics summaryStatistics) {
    Stats stats = new Stats("Column: " + values.name());
    stats.min = (float) summaryStatistics.getMin();
    stats.max = (float) summaryStatistics.getMax();
    stats.n = summaryStatistics.getN();
    stats.sum = summaryStatistics.getSum();
    stats.variance = summaryStatistics.getVariance();
    stats.populationVariance = summaryStatistics.getPopulationVariance();
    stats.quadraticMean = summaryStatistics.getQuadraticMean();
    stats.geometricMean = summaryStatistics.getGeometricMean();
    stats.mean = summaryStatistics.getMean();
    stats.standardDeviation = summaryStatistics.getStandardDeviation();
    stats.sumOfLogs = summaryStatistics.getSumOfLogs();
    stats.sumOfSquares = summaryStatistics.getSumsq();
    stats.secondMoment = summaryStatistics.getSecondMoment();
    return stats;
}
 
开发者ID:jtablesaw,项目名称:tablesaw,代码行数:18,代码来源:Stats.java

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

示例3: calculateOverallAnnotationSufficiencyForAttributeSet

import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
public double calculateOverallAnnotationSufficiencyForAttributeSet(Set<OWLClass> atts) throws UnknownOWLClassException {
	SummaryStatistics stats = computeAttributeSetSimilarityStats(atts);
	if ((this.getSummaryStatistics() == null) || Double.isNaN(this.getSummaryStatistics().mean.getMean())) {
		LOG.info("Stats have not been computed yet - doing this now");
		this.computeSystemStats();
	}
	// score = mean(atts)/mean(overall) + max(atts)/max(overall) + sum(atts)/mean(sum(overall))
	double overall_score = 0.0;
	Double mean_score = stats.getMean();
	Double max_score = stats.getMax();
	Double sum_score = stats.getSum();
	if (!(mean_score.isNaN() || max_score.isNaN() || sum_score.isNaN())) {
		mean_score = StatUtils.min(new double[]{(mean_score / this.overallSummaryStatsPerIndividual.mean.getMean()),1.0});
		max_score = StatUtils.min(new double[]{(max_score / this.overallSummaryStatsPerIndividual.max.getMax()),1.0});
		sum_score = StatUtils.min(new double[]{(sum_score / this.overallSummaryStatsPerIndividual.sum.getMean()),1.0});
		overall_score = (mean_score + max_score + sum_score) / 3;		
	}
	LOG.info("Overall mean: "+mean_score + " max: "+max_score + " sum:"+sum_score + " combined:"+overall_score);
	return overall_score;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:21,代码来源:AbstractOwlSim.java

示例4: calculateSubgraphAnnotationSufficiencyForAttributeSet

import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
public double calculateSubgraphAnnotationSufficiencyForAttributeSet(Set<OWLClass> atts, OWLClass c) throws UnknownOWLClassException {
	SummaryStatistics stats = computeAttributeSetSimilarityStatsForSubgraph(atts,c);
	//TODO: compute statsPerIndividual for this subgraph
	if ((this.overallSummaryStatsPerIndividual == null ) || (Double.isNaN(this.overallSummaryStatsPerIndividual.max.getMean()))) {
		LOG.info("Stats have not been computed yet - doing this now");
		this.computeSystemStats();
	}

	if (!(this.subgraphSummaryStatsPerIndividual.containsKey(c))) {
		//only do this once for the whole system, per class requested
		this.computeSystemStatsForSubgraph(c);
	}
	// score = mean(atts)/mean(overall) + max(atts)/max(overall) + sum(atts)/mean(sum(overall))
	//TODO: need to normalize this based on the whole corpus
	double score = 0.0;
	Double mean_score = stats.getMean();
	Double max_score = stats.getMax();
	Double sum_score = stats.getSum();

	if (!(mean_score.isNaN() || max_score.isNaN() || sum_score.isNaN())) {
		mean_score = StatUtils.min(new double[]{(mean_score / this.subgraphSummaryStatsPerIndividual.get(c).mean.getMean()),1.0});
		max_score = StatUtils.min(new double[]{(max_score / this.subgraphSummaryStatsPerIndividual.get(c).max.getMax()),1.0});
		sum_score = StatUtils.min(new double[]{(sum_score / this.subgraphSummaryStatsPerIndividual.get(c).sum.getMean()),1.0});
		score = (mean_score + max_score + sum_score) / 3;		
	}
	LOG.info(getShortId(c)+" n: "+stats.getN()+" mean: "+mean_score + " max: "+max_score + " sum:"+sum_score + " combined:"+score);
	return score;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:29,代码来源:AbstractOwlSim.java

示例5: add

import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
@Override
public void add(String cacheName, TransactionStats txStats)
{
    boolean registerCacheStats = false;
    WriteLock writeLock = getWriteLock(cacheName);
    writeLock.lock();
    try
    {
        // Are we adding new stats for a previously unseen cache?
        registerCacheStats = !cacheToStatsMap.containsKey(cacheName);
        if (registerCacheStats)
        {
            // There are no statistics yet for this cache. 
            cacheToStatsMap.put(cacheName, new HashMap<OpType, OperationStats>());
        }
        Map<OpType, OperationStats> cacheStats = cacheToStatsMap.get(cacheName);
        
        for (OpType opType : OpType.values())
        {                
            SummaryStatistics txOpSummary = txStats.getTimings(opType);
            long count = txOpSummary.getN();
            double totalTime = txOpSummary.getSum();
                
            OperationStats oldStats = cacheStats.get(opType);
            OperationStats newStats;
            if (oldStats == null)
            {
                newStats = new OperationStats(totalTime, count);
            }
            else
            {
                newStats = new OperationStats(oldStats, totalTime, count);
            }
            cacheStats.put(opType, newStats);
        }
    }
    finally
    {
        writeLock.unlock();
    }
    
    if (registerCacheStats)
    {
        // We've added stats for a previously unseen cache, raise an event
        // so that an MBean for the cache may be registered, for example. 
        applicationContext.publishEvent(new CacheStatisticsCreated(this, cacheName));
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:49,代码来源:InMemoryCacheStatistics.java

示例6: anovaStats

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

    MathUtils.checkNotNull(categoryData);

    if (!allowOneElementData) {
        // check if we have enough categories
        if (categoryData.size() < 2) {
            throw new DimensionMismatchException(LocalizedFormats.TWO_OR_MORE_CATEGORIES_REQUIRED,
                                                 categoryData.size(), 2);
        }

        // check if each category has enough data
        for (final SummaryStatistics array : categoryData) {
            if (array.getN() <= 1) {
                throw new DimensionMismatchException(LocalizedFormats.TWO_OR_MORE_VALUES_IN_CATEGORY_REQUIRED,
                                                     (int) array.getN(), 2);
            }
        }
    }

    int dfwg = 0;
    double sswg = 0;
    double totsum = 0;
    double totsumsq = 0;
    int totnum = 0;

    for (final SummaryStatistics data : categoryData) {

        final double sum = data.getSum();
        final double sumsq = data.getSumsq();
        final int num = (int) data.getN();
        totnum += num;
        totsum += sum;
        totsumsq += sumsq;

        dfwg += num - 1;
        final double ss = sumsq - ((sum * sum) / num);
        sswg += ss;
    }

    final double sst = totsumsq - ((totsum * totsum) / totnum);
    final double ssbg = sst - sswg;
    final int dfbg = categoryData.size() - 1;
    final double msbg = ssbg / dfbg;
    final double mswg = sswg / dfwg;
    final double F = msbg / mswg;

    return new AnovaStats(dfbg, dfwg, F);

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


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