List of usage examples for org.apache.commons.math3.stat.descriptive DescriptiveStatistics DescriptiveStatistics
public DescriptiveStatistics()
From source file:com.insightml.evaluation.functions.MeanAbsoluteError.java
@Override public DescriptiveStatistics acrossLabels( final List<? extends Predictions<? extends Number, ? extends Number>>[] predictions) { final DescriptiveStatistics stats = new DescriptiveStatistics(); for (final List<? extends Predictions<? extends Number, ? extends Number>> predz : predictions) { for (final Predictions<? extends Number, ? extends Number> preds : predz) { final Number[] pred = preds.getPredictions(); final Number[] exp = preds.getExpected(); for (int i = 0; i < pred.length; ++i) { if (exp[i] != null) { stats.addValue(instance(pred[i], exp[i], preds.getSample(i))); }//w w w . jav a 2 s . c om } } } return stats; }
From source file:algorithms.quality.JndRegionSize.java
@Override public double getQuality(Colormap2D colormap) { JndRegionComputer computer = new JndRegionComputer(colormap, sampling, 3.0); DescriptiveStatistics stats = new DescriptiveStatistics(); for (Point2D center : computer.getPoints()) { List<Point2D> poly = computer.getRegion(center); double area = computeArea(poly, center); stats.addValue(area);//w ww .ja v a2 s .c om } // TODO: find a better scaling factor return stats.getVariance() * 10000000.d; }
From source file:algorithms.quality.AttentionQuality.java
@Override public double getQuality(Colormap2D colormap) { // max L + max c (which is the same as a or b) double normFac = Math.sqrt(100 * 100 + 150 * 150); DescriptiveStatistics stats = new DescriptiveStatistics(); for (Point2D pt : sampling.getPoints()) { Color color = colormap.getColor(pt.getX(), pt.getY()); double[] lch = new CIELABLch().fromColor(color); double attention = Math.sqrt(lch[0] * lch[0] + lch[1] * lch[1]) / normFac; stats.addValue(attention);// w w w . ja v a 2 s . c o m } return stats.getVariance(); }
From source file:com.andrewkroh.common.math.PoissonProcessTester.java
@Before public void setup() { stats = new DescriptiveStatistics(); process = new PoissonProcess(DEFAULT_MEAN); }
From source file:mase.me.MEGenerationalStat.java
@Override public void postBreedingStatistics(EvolutionState state) { super.postBreedingStatistics(state); MESubpopulation pop = (MESubpopulation) state.population.subpops[0]; DescriptiveStatistics fit = new DescriptiveStatistics(); for (Individual ind : pop.map.values()) { fit.addValue(((ExpandedFitness) ind.fitness).getFitnessScore()); }/* w ww . j av a2s. c o m*/ state.output.println(state.generation + " " + pop.map.keySet().size() + " " + pop.map.size() + " " + fit.getMin() + " " + fit.getMean() + " " + fit.getMax() + " " + pop.newInRepo, log); state.output.message("Repertoire size: " + pop.map.keySet().size() + " | New: " + pop.newInRepo + " | Avg. fitness: " + new DecimalFormat("0.0000").format(fit.getMean())); }
From source file:com.linkedin.pinot.perf.ForwardIndexReaderBenchmark.java
public static void singleValuedReadBenchMarkV1(File file, int numDocs, int columnSizeInBits) throws Exception { boolean signed = false; boolean isMmap = false; PinotDataBuffer heapBuffer = PinotDataBuffer.fromFile(file, ReadMode.heap, FileChannel.MapMode.READ_ONLY, "benchmark"); BaseSingleColumnSingleValueReader reader = new com.linkedin.pinot.core.io.reader.impl.v1.FixedBitSingleValueReader( heapBuffer, numDocs, columnSizeInBits, signed); // sequential read long start, end; DescriptiveStatistics stats = new DescriptiveStatistics(); for (int run = 0; run < MAX_RUNS; run++) { start = System.currentTimeMillis(); for (int i = 0; i < numDocs; i++) { int value = reader.getInt(i); }/*from ww w . j av a 2s .co m*/ end = System.currentTimeMillis(); stats.addValue(end - start); } System.out.println(" v1 sequential read stats for " + file.getName()); System.out.println(stats.toString().replaceAll("\n", ", ") + " raw:" + Arrays.toString(stats.getValues())); reader.close(); heapBuffer.close(); }
From source file:com.intuit.tank.persistence.databases.BucketDataItemTest.java
/** * Run the int getPeriod() method test.//from www.j a va2 s .c om * * @throws Exception * * @generatedBy CodePro at 9/10/14 10:32 AM */ @Test public void testGetPeriod_1() throws Exception { BucketDataItem fixture = new BucketDataItem(1, new Date(), new DescriptiveStatistics()); int result = fixture.getPeriod(); assertEquals(1, result); }
From source file:mase.app.playground.PlaygroundSDBCStandardizer.java
@Override public void preInitializationStatistics(EvolutionState state) { super.preInitializationStatistics(state); MasonSimulationProblem prob = (MasonSimulationProblem) state.evaluator.p_problem; PlaygroundSDBCRaw fun = null; for (EvaluationFunction ef : prob.getEvalFunctions()) { if (ef instanceof PlaygroundSDBCRaw) { fun = (PlaygroundSDBCRaw) ef; break; }//from ww w . j a va 2s.com } if (fun == null) { state.output.warning("PlaygroundSDBCRaw evaluation function not found. Standardizer not run."); return; } DescriptiveStatistics[] ds = null; for (int i = 0; i < 1000; i++) { Playground pl = (Playground) prob.getSimState(new HomogeneousGroupController(null), i); pl.start(); double[] s = fun.state(pl); if (ds == null) { ds = new DescriptiveStatistics[s.length]; for (int j = 0; j < s.length; j++) { ds[j] = new DescriptiveStatistics(); } } for (int j = 0; j < s.length; j++) { ds[j].addValue(s[j]); } } double[] means = new double[ds.length]; double[] sds = new double[ds.length]; for (int i = 0; i < ds.length; i++) { means[i] = ds[i].getMean(); sds[i] = ds[i].getStandardDeviation(); state.output.message("Feature " + i + ": Mean: " + ds[i].getMean() + " SD: " + ds[i].getStandardDeviation() + " Min: " + ds[i].getMin() + " Max: " + ds[i].getMax()); } fun.setStandardizationScores(means, sds); }
From source file:mase.spec.SpecialisationStats.java
@Override public void postPreBreedingExchangeStatistics(EvolutionState state) { super.postPreBreedingExchangeStatistics(state); SpecialisationExchanger exc = (SpecialisationExchanger) state.exchanger; state.output.print(state.generation + " " + exc.metaPops.size(), log); // metapop size (min, mean, max) DescriptiveStatistics ds = new DescriptiveStatistics(); for (MetaPopulation mp : exc.metaPops) { ds.addValue(mp.populations.size()); }/*from ww w . j a v a 2 s . c om*/ state.output.print(" " + ds.getMin() + " " + ds.getMean() + " " + ds.getMax(), log); // metapop dispersion (min, mean, max) ds.clear(); for (MetaPopulation mp : exc.metaPops) { double dispersion = 0; for (Integer i : mp.populations) { for (Integer j : mp.populations) { dispersion += exc.distanceMatrix[i][j]; } } ds.addValue(dispersion / (mp.populations.size() * mp.populations.size())); } state.output.print(" " + ds.getMin() + " " + ds.getMean() + " " + ds.getMax(), log); // total number of merges and splits int count = 0; for (MetaPopulation mp : exc.metaPops) { count += mp.waitingIndividuals.size(); } state.output.print(" " + count + " " + exc.splits, log); for (int i = 0; i < exc.prototypeSubs.length; i++) { // MetaPop to which they belong MetaPopulation pop = null; for (int m = 0; m < exc.metaPops.size(); m++) { if (exc.metaPops.get(m).populations.contains(i)) { pop = exc.metaPops.get(m); state.output.print(" " + m, log); } } // Population dispersion state.output.print(" " + exc.originalMatrix[i][i], log); // Normalised distance to internal pops -- include itself -- 1 ds.clear(); for (Integer p : pop.populations) { ds.addValue(exc.distanceMatrix[i][p]); } state.output.print(" " + ds.getMin() + " " + ds.getMean() + " " + ds.getMax(), log); // Normalised distance to external pops ds.clear(); for (MetaPopulation mp : exc.metaPops) { if (mp != pop) { for (Integer p : mp.populations) { ds.addValue(exc.distanceMatrix[i][p]); } } } if (ds.getN() == 0) { ds.addValue(1); } state.output.print(" " + ds.getMin() + " " + ds.getMean() + " " + ds.getMax(), log); } String str = ""; for (MetaPopulation mp : exc.metaPops) { str += mp + " ; "; } state.output.message(str); /*for(double[] m : exc.distanceMatrix) { state.output.message(Arrays.toString(m)); }*/ // representatives /*MetaEvaluator me = (MetaEvaluator) state.evaluator; MultiPopCoevolutionaryEvaluator2 baseEval = (MultiPopCoevolutionaryEvaluator2) me.getBaseEvaluator(); Individual[][] elites = baseEval.getEliteIndividuals(); ds.clear(); for(MetaPopulation mp : exc.metaPops) { HashSet<Individual> inds = new HashSet<Individual>(); for(Integer p : mp.populations) { inds.add(elites[p][0]); } ds.addValue(inds.size() / (double) mp.populations.size()); } state.output.print(" " + ds.getMin() + " " + ds.getMean() + " " + ds.getMax(), log);*/ state.output.println("", log); }
From source file:com.intuit.tank.vm.common.util.ReportUtilCpTest.java
/** * Run the String[] getSummaryData(String,DescriptiveStatistics) method test. * /*from w w w. j a v a 2 s . c o m*/ * @throws Exception * * @generatedBy CodePro at 9/3/14 3:41 PM */ @Test public void testGetSummaryData_1() throws Exception { String key = ""; DescriptiveStatistics stats = new DescriptiveStatistics(); String[] result = ReportUtil.getSummaryData(key, stats); assertNotNull(result); assertEquals(23, result.length); assertEquals("", result[0]); assertEquals("0", result[1]); assertEquals("", result[2]); assertEquals("", result[3]); assertEquals("", result[4]); assertEquals("", result[5]); assertEquals("", result[6]); assertEquals("", result[7]); assertEquals("", result[8]); assertEquals("", result[9]); assertEquals("", result[10]); assertEquals("", result[11]); assertEquals("", result[12]); assertEquals("", result[13]); assertEquals("", result[14]); assertEquals("", result[15]); assertEquals("", result[16]); assertEquals("", result[17]); assertEquals("", result[18]); assertEquals("", result[19]); assertEquals("", result[20]); assertEquals(null, result[21]); assertEquals(null, result[22]); }