View Javadoc
1   package org.kuali.common.devops.jenkins.scan;
2   
3   import static org.kuali.common.util.base.Precondition.checkNotNull;
4   
5   import java.util.List;
6   
7   public class Stats {
8   
9   	public static SummaryStatistics buildSummaryFromDoubles(List<Double> values) {
10  		checkNotNull(values, "values");
11  		org.apache.commons.math3.stat.descriptive.SummaryStatistics ss = new org.apache.commons.math3.stat.descriptive.SummaryStatistics();
12  		for (Double value : values) {
13  			ss.addValue(value);
14  		}
15  		return copyOf(ss);
16  	}
17  
18  	public static SummaryStatistics buildSummaryFromLongs(List<Long> values) {
19  		checkNotNull(values, "values");
20  		org.apache.commons.math3.stat.descriptive.SummaryStatistics ss = new org.apache.commons.math3.stat.descriptive.SummaryStatistics();
21  		for (Long value : values) {
22  			ss.addValue(value);
23  		}
24  		return copyOf(ss);
25  	}
26  
27  	public static SummaryStatistics buildSummaryFromIntegers(List<Integer> values) {
28  		checkNotNull(values, "values");
29  		org.apache.commons.math3.stat.descriptive.SummaryStatistics ss = new org.apache.commons.math3.stat.descriptive.SummaryStatistics();
30  		for (Integer value : values) {
31  			ss.addValue(value);
32  		}
33  		return copyOf(ss);
34  	}
35  
36  	public static SummaryStatistics copyOf(org.apache.commons.math3.stat.descriptive.SummaryStatistics ss) {
37  		return SummaryStatistics.builder().withAvg(ss.getMean()).withCount(ss.getN()).withMax(ss.getMax()).withMin(ss.getMin()).withStandardDeviation(ss.getStandardDeviation())
38  				.withSum(ss.getSum()).withVariance(ss.getVariance()).build();
39  	}
40  
41  }