List of usage examples for org.apache.commons.math3.stat.descriptive DescriptiveStatistics getMean
public double getMean()
From source file:de.tudarmstadt.ukp.experiments.argumentation.convincingness.sampling.Step6GraphTransitivityCleaner.java
@SuppressWarnings("unchecked") public static void printResultStatistics(File xmlFile) throws IllegalAccessException { Map<String, Map<String, GraphCleaningResults>> results = (Map<String, Map<String, GraphCleaningResults>>) XStreamTools .getXStream().fromXML(xmlFile); // System.out.println(results); SortedMap<String, List<GraphCleaningResults>> resultsGroupedByMethod = new TreeMap<>(); for (Map.Entry<String, Map<String, GraphCleaningResults>> entry : results.entrySet()) { // System.out.println(entry.getKey()); for (Map.Entry<String, GraphCleaningResults> e : entry.getValue().entrySet()) { // System.out.println(e.getKey()); // System.out.println(e.getValue()); if (!resultsGroupedByMethod.containsKey(e.getKey())) { resultsGroupedByMethod.put(e.getKey(), new ArrayList<GraphCleaningResults>()); }/*from w ww.ja v a2s . c o m*/ resultsGroupedByMethod.get(e.getKey()).add(e.getValue()); } } String header = null; // collect statistics for (Map.Entry<String, List<GraphCleaningResults>> entry : resultsGroupedByMethod.entrySet()) { List<GraphCleaningResults> value = entry.getValue(); SortedMap<String, DescriptiveStatistics> stringDescriptiveStatisticsMap = collectStatisticsOverGraphCleaningResults( value); if (header == null) { header = StringUtils.join(stringDescriptiveStatisticsMap.keySet(), "\t"); System.out.println("\t\t" + header); } List<Double> means = new ArrayList<>(); List<Double> stdDevs = new ArrayList<>(); for (DescriptiveStatistics statistics : stringDescriptiveStatisticsMap.values()) { means.add(statistics.getMean()); stdDevs.add(statistics.getStandardDeviation()); } List<String> meansString = new ArrayList<>(); for (Double mean : means) { meansString.add(String.format(Locale.ENGLISH, "%.2f", mean)); } List<String> stdDevString = new ArrayList<>(); for (Double stdDev : stdDevs) { stdDevString.add(String.format(Locale.ENGLISH, "%.2f", stdDev)); } System.out.println(entry.getKey() + "\tmean\t" + StringUtils.join(meansString, "\t")); // System.out.println(entry.getKey() + "\tstdDev\t" + StringUtils.join(stdDevString, "\t")); } }
From source file:ijfx.core.overlay.PixelStatisticsBase.java
public PixelStatisticsBase(DescriptiveStatistics stats) { setMean(stats.getMean()); setMax(stats.getMax());/*from w w w.j a va 2 s .c o m*/ setStandardDeviation(stats.getStandardDeviation()); setVariance(stats.getVariance()); setMedian(stats.getPercentile(50)); setPixelCount(stats.getN()); setMin(stats.getMin()); }
From source file:com.fpuna.preproceso.PreprocesoTS.java
private static TrainingSetFeature calculoFeaturesMagnitud(List<Registro> muestras, String activity) { TrainingSetFeature Feature = new TrainingSetFeature(); DescriptiveStatistics stats_m = new DescriptiveStatistics(); double[] fft_m; double[] AR_4; muestras = Util.calcMagnitud(muestras); for (int i = 0; i < muestras.size(); i++) { stats_m.addValue(muestras.get(i).getM_1()); }/*from ww w . ja v a 2 s .c om*/ //********* FFT ********* //fft_m = Util.transform(stats_m.getValues()); fft_m = FFTMixedRadix.fftPowerSpectrum(stats_m.getValues()); //******************* Calculos Magnitud *******************// //mean(s) - Arithmetic mean System.out.print(stats_m.getMean() + ","); Feature.setMeanX((float) stats_m.getMean()); //std(s) - Standard deviation System.out.print(stats_m.getStandardDeviation() + ","); Feature.setStdX((float) stats_m.getStandardDeviation()); //mad(s) - Median absolute deviation // //max(s) - Largest values in array System.out.print(stats_m.getMax() + ","); Feature.setMaxX((float) stats_m.getMax()); //min(s) - Smallest value in array System.out.print(stats_m.getMin() + ","); Feature.setMinX((float) stats_m.getMin()); //skewness(s) - Frequency signal Skewness System.out.print(stats_m.getSkewness() + ","); Feature.setSkewnessX((float) stats_m.getSkewness()); //kurtosis(s) - Frequency signal Kurtosis System.out.print(stats_m.getKurtosis() + ","); Feature.setKurtosisX((float) stats_m.getKurtosis()); //energy(s) - Average sum of the squares System.out.print(stats_m.getSumsq() / stats_m.getN() + ","); Feature.setEnergyX((float) (stats_m.getSumsq() / stats_m.getN())); //entropy(s) - Signal Entropy System.out.print(Util.calculateShannonEntropy(fft_m) + ","); Feature.setEntropyX(Util.calculateShannonEntropy(fft_m).floatValue()); //iqr (s) Interquartile range System.out.print(stats_m.getPercentile(75) - stats_m.getPercentile(25) + ","); Feature.setIqrX((float) (stats_m.getPercentile(75) - stats_m.getPercentile(25))); try { //autoregression (s) -4th order Burg Autoregression coefficients AR_4 = AutoRegression.calculateARCoefficients(stats_m.getValues(), 4, true); System.out.print(AR_4[0] + ","); System.out.print(AR_4[1] + ","); System.out.print(AR_4[2] + ","); System.out.print(AR_4[3] + ","); Feature.setArX1((float) AR_4[0]); Feature.setArX2((float) AR_4[1]); Feature.setArX3((float) AR_4[2]); Feature.setArX4((float) AR_4[3]); } catch (Exception ex) { Logger.getLogger(PreprocesoTS.class.getName()).log(Level.SEVERE, null, ex); } //meanFreq(s) - Frequency signal weighted average System.out.print(Util.meanFreq(fft_m, stats_m.getValues()) + ","); Feature.setMeanFreqx((float) Util.meanFreq(fft_m, stats_m.getValues())); //******************* Actividad *******************/ System.out.print(activity); System.out.print("\n"); Feature.setEtiqueta(activity); return Feature; }
From source file:com.insightml.data.features.stats.FeatureStatistics.java
public Double getMean(final String feature) { final DescriptiveStatistics stat = stats.get(feature); return stat == null ? null : stat.getMean(); }
From source file:ijfx.core.overlay.DefaultPixelStatistics.java
public DefaultPixelStatistics(ImageDisplay display, Overlay overlay, Context context) { context.inject(this); Double[] valueList = overlayStatService.getValueListFromImageDisplay(display, overlay); DescriptiveStatistics statistics = new DescriptiveStatistics(ArrayUtils.toPrimitive(valueList)); this.mean = statistics.getMean(); this.max = statistics.getMax(); this.min = statistics.getMin(); this.standardDeviation = statistics.getStandardDeviation(); this.variance = statistics.getVariance(); this.median = statistics.getPercentile(MEDIAN_PERCENTILE); this.pixelCount = valueList.length; }
From source file:ijfx.service.overlay.DefaultPixelStatistics.java
public DefaultPixelStatistics(ImageDisplay display, Overlay overlay, Context context) { context.inject(this); Double[] valueList = overlayStatService.getValueList(display, overlay); DescriptiveStatistics statistics = new DescriptiveStatistics(ArrayUtils.toPrimitive(valueList)); this.mean = statistics.getMean(); this.max = statistics.getMax(); this.min = statistics.getMin(); this.standardDeviation = statistics.getStandardDeviation(); this.variance = statistics.getVariance(); this.median = statistics.getPercentile(MEDIAN_PERCENTILE); this.pixelCount = valueList.length; }
From source file:com.insightml.models.meta.VoteModel.java
private double resolve(final DescriptiveStatistics stats) { switch (strategy) { case AVERAGE: return stats.getMean(); case MEDIAN:/* ww w . ja va 2 s . c o m*/ return stats.getPercentile(50); case GEOMETRIC: return stats.getGeometricMean(); case HARMONIC: double sum = 0; for (final double value : stats.getValues()) { sum += 1 / value; } return stats.getN() * 1.0 / sum; default: throw new IllegalStateException(); } }
From source file:cc.kave.commons.pointsto.evaluation.PointsToSetEvaluation.java
public void run(Path contextsDir) throws IOException { StatementCounterVisitor stmtCounterVisitor = new StatementCounterVisitor(); List<Context> contexts = getSamples(contextsDir).stream() .filter(cxt -> cxt.getSST().accept(stmtCounterVisitor, null) > 0).collect(Collectors.toList()); log("Using %d contexts for evaluation\n", contexts.size()); PointsToUsageExtractor extractor = new PointsToUsageExtractor(); for (Context context : contexts) { PointstoSetSizeAnalysis analysis = new PointstoSetSizeAnalysis(); extractor.extract(analysis.compute(context)); results.addAll(analysis.getSetSizes()); }/*from w w w.ja v a 2 s. c o m*/ DescriptiveStatistics statistics = new DescriptiveStatistics(); for (Integer setSize : results) { statistics.addValue(setSize.doubleValue()); } log("mean: %.2f\n", statistics.getMean()); log("stddev: %.2f\n", statistics.getStandardDeviation()); log("min/max: %.2f/%.2f\n", statistics.getMin(), statistics.getMax()); }
From source file:cz.cuni.mff.d3s.tools.perfdoc.server.measuring.statistics.Statistics.java
public long computeMedian() { if (measurementResults.isEmpty()) { return -1; }/*from ww w . java 2s . c o m*/ DescriptiveStatistics stats = new DescriptiveStatistics(); for (Long l : measurementResults) { stats.addValue(l); } return (long) stats.getMean(); }
From source file:com.datatorrent.netlet.benchmark.util.BenchmarkResults.java
private String getResults() { DescriptiveStatistics statistics = getDescriptiveStatistics(); final StringBuilder sb = new StringBuilder(); sb.append("Iterations: ").append(statistics.getN()); sb.append(" | Avg Time: ").append(fromNanoTime(statistics.getMean())); sb.append(" | Min Time: ").append(fromNanoTime(statistics.getMin())); sb.append(" | Max Time: ").append(fromNanoTime(statistics.getMax())); sb.append(" | 75% Time: ").append(fromNanoTime(statistics.getPercentile(75d))); sb.append(" | 90% Time: ").append(fromNanoTime(statistics.getPercentile(90d))); sb.append(" | 99% Time: ").append(fromNanoTime(statistics.getPercentile(99d))); sb.append(" | 99.9% Time: ").append(fromNanoTime(statistics.getPercentile(99.9d))); sb.append(" | 99.99% Time: ").append(fromNanoTime(statistics.getPercentile(99.99d))); sb.append(" | 99.999% Time: ").append(fromNanoTime(statistics.getPercentile(99.999d))); return sb.toString(); }