List of usage examples for org.apache.commons.math3.stat.descriptive DescriptiveStatistics getMean
public double getMean()
From source file:knop.psfj.utils.MathUtils.java
/** * Format statistics.// ww w .ja v a 2 s.co m * * @param stats the stats * @param unit the unit * @return the string */ public static String formatStatistics(DescriptiveStatistics stats, String unit) { String value = MathUtils.formatDouble(stats.getMean(), unit); System.out.println("number after dot : " + getNumberAfterDot(value)); String variation = MathUtils.formatDouble(stats.getStandardDeviation(), unit, getNumberAfterDot(value)); return String.format("%s %s %s", value, PLUS_MINUS, variation); }
From source file:de.tudarmstadt.ukp.experiments.argumentation.sequence.evaluation.thirdparty.SegEvalEvaluator.java
/** * Computes upper bounds by computing segment boundaries on three annotators * * @throws Exception//from ww w. ja va2 s . co m */ public static void segmentEvaluationThreeAnnotators() throws Exception { File parentFolder = new File( "/usr/local/data/argumentation/all-annotations-phase2-exported/new-typesystem"); for (String folderName : Arrays.asList("phase2-final-annotator1", "phase2-final-annotator2", "phase2-final-annotator3")) { File annotatorFolder = new File(parentFolder, folderName); SegEvalEvaluator evaluator = new SegEvalEvaluator(); DescriptiveStatistics statistics = evaluator.evaluateFolders(new File(goldDataPath), annotatorFolder, ArgumentComponent.class); System.out.printf("%.3f +- %.3f", statistics.getMean(), statistics.getStandardDeviation()); } }
From source file:async.nio2.Main.java
private static String toEvaluationString(DescriptiveStatistics stats) { String data = String.format( "0.50 Percentile = %8.2f, " + "0.90 Percentile = %8.2f, " + "0.99 Percentile = %8.2f, " + "min = %8.2f, " + "max = %8.2f", stats.getMean(), stats.getPercentile(90), stats.getPercentile(99), stats.getMin(), stats.getMax()); stats.clear();/*ww w.j a v a 2s. co m*/ return data; }
From source file:com.spotify.annoy.jni.base.Benchmark.java
private static void dispStats(List<Long> queryTime) { DescriptiveStatistics s = new DescriptiveStatistics(); for (Long t : queryTime) { s.addValue(t);/*ww w . j a va 2 s . c o m*/ } System.out.print(new StringBuilder().append(String.format("Total time: %.5fs\n", s.getSum() / 1.e9)) .append(String.format("Mean time: %.5fs\n", s.getMean() / 1.e9)) .append(String.format("Median time: %.5fs\n", s.getPercentile(.5) / 1.e9)) .append(String.format("Stddev time: %.5fs\n", s.getStandardDeviation() / 1.e9)) .append(String.format("Min time: %.5fs\n", s.getMin() / 1.e9)) .append(String.format("Max time: %.5fs\n", s.getMax() / 1.e9)).toString()); }
From source file:com.candy.algo.SMA.java
public static double[] Sma(double inputs[], int windowSize) { // Get a DescriptiveStatistics instance DescriptiveStatistics stats = new DescriptiveStatistics(); stats.setWindowSize(windowSize);/*from w ww . jav a2 s . com*/ double[] sma = new double[inputs.length]; for (int i = 0; i < inputs.length; i++) { stats.addValue(inputs[i]); if (i >= (windowSize - 1)) sma[i] = stats.getMean(); else sma[i] = Double.NaN; } return sma; }
From source file:com.teradata.benchto.service.model.AggregatedMeasurement.java
public static AggregatedMeasurement aggregate(MeasurementUnit unit, Collection<Double> values) { if (values.size() < 2) { Double value = Iterables.getOnlyElement(values); return new AggregatedMeasurement(unit, value, value, value, 0.0, 0.0); }// w ww . j a va 2 s. co m DescriptiveStatistics statistics = new DescriptiveStatistics( values.stream().mapToDouble(Double::doubleValue).toArray()); double stdDevPercent = 0.0; if (statistics.getStandardDeviation() > 0.0) { stdDevPercent = (statistics.getStandardDeviation() / statistics.getMean()) * 100; } return new AggregatedMeasurement(unit, statistics.getMin(), statistics.getMax(), statistics.getMean(), statistics.getStandardDeviation(), stdDevPercent); }
From source file:com.screenslicer.core.util.StringUtil.java
public static void trimLargeItems(int[] stringLengths, List<? extends Object> originals) { DescriptiveStatistics stats = new DescriptiveStatistics(); for (int i = 0; i < stringLengths.length; i++) { stats.addValue(stringLengths[i]); }/*w w w . jav a 2s.c o m*/ double stdDev = stats.getStandardDeviation(); double mean = stats.getMean(); List<Object> toRemove = new ArrayList<Object>(); for (int i = 0; i < stringLengths.length; i++) { double diff = stringLengths[i] - mean; if (diff / stdDev > 4d) { toRemove.add(originals.get(i)); } } for (Object obj : toRemove) { originals.remove(obj); } }
From source file:com.intuit.tank.service.impl.v1.report.SummaryReportRunner.java
/** * @param jobId/*from w w w. j a v a 2 s .c o m*/ * @param key * @param stats * @return */ private static PeriodicData getBucketData(int jobId, String key, BucketDataItem bucketItem) { DescriptiveStatistics stats = bucketItem.getStats(); PeriodicData ret = PeriodicDataBuilder.periodicData().withJobId(jobId).withMax(stats.getMax()) .withMean(stats.getMean()).withMin(stats.getMin()).withPageId(key) .withSampleSize((int) stats.getN()).withPeriod(bucketItem.getPeriod()) .withTimestamp(bucketItem.getStartTime()).build(); return ret; }
From source file:com.intuit.tank.vm.common.util.ReportUtil.java
public static final String[] getSummaryData(String key, DescriptiveStatistics stats) { String[] ret = new String[ReportUtil.SUMMARY_HEADERS.length + PERCENTILES.length]; int i = 0;// ww w . j a va 2 s. co m ret[i++] = key;// Page ID ret[i++] = INT_NF.format(stats.getN());// Sample Size ret[i++] = DOUBLE_NF.format(stats.getMean());// Mean ret[i++] = INT_NF.format(stats.getPercentile(50));// Meadian ret[i++] = INT_NF.format(stats.getMin());// Min ret[i++] = INT_NF.format(stats.getMax());// Max ret[i++] = DOUBLE_NF.format(stats.getStandardDeviation());// Std Dev ret[i++] = DOUBLE_NF.format(stats.getKurtosis());// Kurtosis ret[i++] = DOUBLE_NF.format(stats.getSkewness());// Skewness ret[i++] = DOUBLE_NF.format(stats.getVariance());// Varience for (int n = 0; n < PERCENTILES.length; n++) { ret[i++] = INT_NF.format(stats.getPercentile((Integer) PERCENTILES[n][1]));// Percentiles } return ret; }
From source file:net.adamjak.thomas.graph.application.commons.StatisticsUtils.java
public static DescriptiveStatistics statisticsWithoutExtremes(DescriptiveStatistics inputStatistics, GrubbsLevel grubbsLevel) throws IllegalArgumentException { if (inputStatistics == null || grubbsLevel == null) throw new IllegalArgumentException("Params inputStatistics and grubbsLevel can not be null."); int countInput = inputStatistics.getValues().length; Double avgInput = inputStatistics.getMean(); Double stdInput = inputStatistics.getStandardDeviation(); Double s = stdInput * Math.sqrt((countInput - 1.0) / countInput); Double criticalValue = grubbsLevel.getCriticalValue(countInput); DescriptiveStatistics outputStatistic = new DescriptiveStatistics(); for (double inpVal : inputStatistics.getValues()) { double test = Math.abs(inpVal - avgInput) / s; if (test <= criticalValue) { outputStatistic.addValue(inpVal); }//from ww w.ja va 2 s . c o m } return outputStatistic; }