Java源码示例:org.apache.commons.math3.stat.descriptive.AggregateSummaryStatistics
示例1
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);
}
示例2
public Map<TabletStatisticType, StatisticalSummary> aggregateSummary() {
// @formatter:off
return tabletStats.stream()
.flatMap(m -> m.getSummaryMap().entrySet().stream())
.collect(Collectors.groupingBy(Map.Entry::getKey,
Collectors.mapping(Map.Entry::getValue, Collectors.toList())))
.entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getKey, v -> AggregateSummaryStatistics.aggregate(v.getValue())));
}
示例3
public void computeSystemStats() throws UnknownOWLClassException {
Set<OWLNamedIndividual> insts = this.getAllElements();
LOG.info("Computing system stats for " + insts.size() + " individuals");
LOG.info("Creating singular stat scores for all IDspaces");
Collection<SummaryStatistics> aggregate = new ArrayList<SummaryStatistics>();
this.overallStats = new SummaryStatistics();
int counter = 0;
for (OWLNamedIndividual i : insts) {
counter++;
SummaryStatistics statsPerIndividual = computeIndividualStats(i);
//put this individual into the aggregate
if (statsPerIndividual.getN() == 0) {
LOG.error("No annotations found for Individual "+i.toStringID());
} else {
aggregate.add(statsPerIndividual);
}
//TODO: put this individual into an idSpace aggregate
// String idSpace = i.getIRI().getNamespace();
this.overallStats.addValue(statsPerIndividual.getMean());
if (counter % 1000 == 0) {
LOG.info("Finished "+counter+" individuals");
}
}
// this.aggregateStatsPerIndividual = AggregateSummaryStatistics.aggregate(aggregate);
StatsPerIndividual myStats = new StatsPerIndividual();
myStats.mean = getSummaryStatisticsForCollection(aggregate,Stat.MEAN);
myStats.sum = getSummaryStatisticsForCollection(aggregate,Stat.SUM);
myStats.min = getSummaryStatisticsForCollection(aggregate,Stat.MIN);
myStats.max = getSummaryStatisticsForCollection(aggregate,Stat.MAX);
myStats.n = getSummaryStatisticsForCollection(aggregate,Stat.N);
myStats.aggregate = AggregateSummaryStatistics.aggregate(aggregate);
this.overallSummaryStatsPerIndividual = myStats;
LOG.info("Finished computing overall statsPerIndividual:\n"+this.getSummaryStatistics().toString());
}