List of usage examples for org.apache.commons.math3.stat.descriptive DescriptiveStatistics getMin
public double getMin()
From source file:mase.stat.FitnessStat.java
/** * Prints out the statistics, but does not end with a println -- this lets * overriding methods print additional statistics on the same line *//*from ww w.j a v a 2 s . c o m*/ @Override public void postEvaluationStatistics(final EvolutionState state) { super.postEvaluationStatistics(state); int subpops = state.population.subpops.length; // number of supopulations DescriptiveStatistics[] fitness = new DescriptiveStatistics[subpops]; for (int i = 0; i < subpops; i++) { fitness[i] = new DescriptiveStatistics(); } int evals = state.evaluator.p_problem instanceof MaseProblem ? ((MaseProblem) state.evaluator.p_problem).getTotalEvaluations() : 0; // gather per-subpopulation statistics for (int x = 0; x < subpops; x++) { for (int y = 0; y < state.population.subpops[x].individuals.length; y++) { if (state.population.subpops[x].individuals[y].evaluated) {// he's got a valid fitness // update fitness double f = ((ExpandedFitness) state.population.subpops[x].individuals[y].fitness) .getFitnessScore(); bestSoFar[x] = Math.max(bestSoFar[x], f); absoluteBest = Math.max(absoluteBest, f); fitness[x].addValue(f); } } // print out fitness information if (doSubpops) { state.output.println(state.generation + " " + evals + " " + x + " " + fitness[x].getN() + " " + fitness[x].getMin() + " " + fitness[x].getMean() + " " + fitness[x].getMax() + " " + bestSoFar[x], statisticslog); } } // Now gather global statistics DescriptiveStatistics global = new DescriptiveStatistics(); for (DescriptiveStatistics ds : fitness) { for (double v : ds.getValues()) { global.addValue(v); } } state.output.println(state.generation + " " + evals + " NA " + global.getN() + " " + global.getMin() + " " + global.getMean() + " " + global.getMax() + " " + absoluteBest, statisticslog); }
From source file:com.tascape.reactor.report.SuiteResultView.java
private void processMetrics() { Map<String, Map<String, Object>> tm = new HashMap<>(); this.caseMetrics.forEach(row -> { String key = row.get(CaseResultMetric.METRIC_GROUP) + "." + row.get(CaseResultMetric.METRIC_NAME); Map<String, Object> r = tm.get(key); if (r == null) { tm.put(key, row);/* w w w . j a va2 s . c o m*/ List<Double> values = new ArrayList<>(); values.add((double) row.get(CaseResultMetric.METRIC_VALUE)); row.put("values", values); } else { @SuppressWarnings("unchecked") List<Double> values = (List<Double>) r.get("values"); values.add((double) row.get(CaseResultMetric.METRIC_VALUE)); } }); tm.values().stream().forEach(row -> { @SuppressWarnings("unchecked") List<Double> values = (List<Double>) row.get("values"); if (values.size() > 1) { DescriptiveStatistics stats = new DescriptiveStatistics(); values.forEach(v -> stats.addValue(v)); row.put("max", stats.getMax()); row.put("min", stats.getMin()); row.put("mean", stats.getMean()); row.put("size", values.size()); } }); this.caseMetrics = new ArrayList<>(tm.values()); }
From source file:io.yields.math.framework.DomainTest.java
@Explore(name = "Test Variable Distribution", dataProvider = DataProviders.FixedMersenneTwisterDataProvider.class) @Exploration(name = "Test Function", context = FunctionExplorerContext.class, group = "domain") public void testVariableDistribution(Explorer<Double> explorer) { assertThat(explorer.all().count()).isEqualTo(explorer.valid().count()); assertThat(explorer.valid().count()).isEqualTo(explorer.valid().count()); assertThat(explorer.invalid().count()).isEqualTo(0); assertThat(explorer.propertyError().count()).isEqualTo(0); DescriptiveStatistics stats = new DescriptiveStatistics(); explorer.all().forEach(result -> stats.addValue(result.getFunctionOutcome().orElse(0d))); assertThat(stats.getMean()).isEqualTo(0, delta(0.1)); assertThat(stats.getMax()).isEqualTo(1, delta(0.1)); assertThat(stats.getMin()).isEqualTo(-1, delta(0.1)); }
From source file:io.yields.math.framework.DomainTest.java
@Explore(name = "Test Variable Distribution with multiple properties", dataProvider = DataProviders.FixedMersenneTwisterDataProvider.class) @Exploration(name = "Test Function", context = FunctionExplorerMultiplePropertiesContext.class, group = "domain") public void testVariableDistributionMultipleProperties(Explorer<Double> explorer) { assertThat(explorer.all().count()).isEqualTo(explorer.valid().count()); assertThat(explorer.valid().count()).isEqualTo(explorer.valid().count()); assertThat(explorer.invalid().count()).isEqualTo(0); assertThat(explorer.propertyError().count()).isEqualTo(0); DescriptiveStatistics stats = new DescriptiveStatistics(); explorer.all().forEach(result -> stats.addValue(result.getFunctionOutcome().orElse(0d))); assertThat(stats.getMean()).isEqualTo(0, delta(0.1)); assertThat(stats.getMax()).isEqualTo(1, delta(0.1)); assertThat(stats.getMin()).isEqualTo(-1, delta(0.1)); }
From source file:io.yields.math.framework.DomainTest.java
@Explore(name = "Multiple Explorations", dataProvider = DataProviders.FixedMersenneTwisterDataProvider.class) @Exploration(name = "Test Function", context = FunctionExplorerContext.class, group = "domain") @Exploration(name = "Test Function 2", context = Function2ExplorerContext.class, group = "domain") public void testMultipleExplorations(List<Explorer<Double>> explorers) { for (Explorer<Double> explorer : explorers) { assertThat(explorer.all().count()).isEqualTo(explorer.valid().count()); assertThat(explorer.invalid().count()).isEqualTo(0); assertThat(explorer.propertyError().count()).isEqualTo(0); DescriptiveStatistics stats = new DescriptiveStatistics(); explorer.all().forEach(result -> stats.addValue(result.getFunctionOutcome().orElse(0d))); assertThat(stats.getMean()).isEqualTo(0, delta(0.1)); assertThat(stats.getMax()).isEqualTo(1, delta(0.1)); assertThat(stats.getMin()).isEqualTo(-1, delta(0.1)); }//ww w . j a va2 s .com // compare 2 explorers Explorer<Double> firstExplorer = explorers.get(0); Explorer<Double> secondExplorer = explorers.get(1); List<PropertyVerifications<Double>> resultsOfFirstExplorer = firstExplorer.all() .collect(Collectors.toList()); List<PropertyVerifications<Double>> resultsOfSecondExplorer = secondExplorer.all() .collect(Collectors.toList()); for (int i = 0; i < resultsOfFirstExplorer.size(); i++) { assertThat(resultsOfFirstExplorer.get(i).getFunctionOutcome().orElse(0d)) .isEqualTo(resultsOfSecondExplorer.get(i).getFunctionOutcome().orElse(0d), delta(2d)); } }
From source file:com.duy.pascal.interperter.libraries.math.MathLib.java
@PascalMethod(description = "") public double MinValue(double... arr) { DescriptiveStatistics descriptiveStatistics1 = new DescriptiveStatistics(arr); return descriptiveStatistics1.getMin(); }
From source file:com.duy.pascal.interperter.libraries.math.MathLib.java
@PascalMethod(description = "") public int MinIntValue(int... arr) { double[] copy = new double[arr.length]; for (int i = 0; i < arr.length; i++) { copy[i] = arr[i];// w w w . j a v a2s. c om } DescriptiveStatistics descriptiveStatistics1 = new DescriptiveStatistics(copy); return (int) descriptiveStatistics1.getMin(); }
From source file:com.linuxbox.enkive.statistics.consolidation.AbstractConsolidator.java
/** * Builds a map that cooresponds to the consolidation methods * /* ww w . ja va 2s .com*/ * @param method * - the method to use * @param exampleData * - an example data object (for type consistancy after * consolidation) * @param statsMaker * - the pre-populated DescriptiveStatstistics object to pull * stats from * @param statData * - the map to populate with consolidated data */ public void methodMapBuilder(String method, DescriptiveStatistics statsMaker, Map<String, Object> statData) { if (method.equals(CONSOLIDATION_SUM)) { statData.put(method, statsMaker.getSum()); } else if (method.equals(CONSOLIDATION_MAX)) { statData.put(method, statsMaker.getMax()); } else if (method.equals(CONSOLIDATION_MIN)) { statData.put(method, statsMaker.getMin()); } else if (method.equals(CONSOLIDATION_AVG)) { statData.put(method, statsMaker.getMean()); } }
From source file:org.sakaiproject.gradebookng.tool.panels.SettingsGradingSchemaPanel.java
/** * Calculates the min grade for the course * /* ww w . j av a2s . c o m*/ * @return String min grade */ private String getMin(DescriptiveStatistics stats) { return this.total > 0 ? String.format("%.2f", 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 w w w . jav a 2 s. co m*/ //********* 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; }