List of usage examples for org.apache.commons.math3.stat.descriptive DescriptiveStatistics getMax
public double getMax()
From source file:io.yields.math.concepts.operator.SmoothnessTest.java
@Spec(name = "linear data - quadraticSmoothness", functional = SmoothnessTest.LinearData.class) public void testLinearData_quadraticSmoothness(FunctionalContext<List<Tuple>> context) { //second order matching as well DescriptiveStatistics stats = new Smoothness(2).apply(context.evaluate()); assertThat(stats.getMin()).isEqualTo(stats.getMax(), Delta.delta(1.e-8)).isEqualTo(0d, Delta.delta(1.e-8)); }
From source file:io.yields.math.concepts.operator.SmoothnessTest.java
@Spec(name = "quadratic data - quadratic smoothness", functional = SmoothnessTest.QuadraticData.class) public void testQuadraticCase_quadraticSmoothness(FunctionalContext<List<Tuple>> context) { //second order matching as well DescriptiveStatistics stats = new Smoothness(2).apply(context.evaluate()); assertThat(stats.getMin()).isEqualTo(stats.getMax(), Delta.delta(1.e-8)).isEqualTo(0d, Delta.delta(1.e-8)); }
From source file:io.realm.datastorebenchmark.DataStoreTest.java
public void saveMeasurements(String filePrefix) { String tag = getTag();/*w w w .jav a 2s . com*/ try { // one file per test with raw data for (String key : keys) { File file1 = new File(Environment.getExternalStorageDirectory() + "/datastorebenchmark", tag + "_" + key + ".csv"); FileOutputStream fileOutputStream1 = new FileOutputStream(file1, false); List<Long> measurement = measurements.get(key); for (int i = 0; i < measurement.size(); i++) { fileOutputStream1.write(String.format("%d\n", measurement.get(i).longValue()).getBytes()); } fileOutputStream1.close(); } // combined CSV file File file = new File(Environment.getExternalStorageDirectory() + "/datastorebenchmark", filePrefix + ".csv"); FileOutputStream fileOutputStream = new FileOutputStream(file, true); fileOutputStream.write(String.format("%s;", tag).getBytes()); for (String key : keys) { List<Long> measurement = measurements.get(key); double[] doubles = new double[measurement.size()]; for (int i = 0; i < measurement.size(); i++) { doubles[i] = measurement.get(i).doubleValue(); } Collections.sort(measurement); DescriptiveStatistics results = new DescriptiveStatistics(doubles); fileOutputStream.write(String .format("%e;%e;%e;", results.getMin(), results.getMax(), results.getMean()).getBytes()); } fileOutputStream.write("\n".getBytes()); fileOutputStream.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.soulgalore.web.pagesavings.reporters.SystemOutReporter.java
public void report(Set<SiteResult> results, Map<String, DescriptiveStatistics> statistics) { Double totalPw = 0D;//from w ww . j a v a 2 s .com Double totalUnique = 0D; for (SiteResult siteResult : results) { totalPw += siteResult.getTotalSavings() * siteResult.getSite().getPageViews(); totalUnique += siteResult.getTotalSavings() * siteResult.getSite().getUniqueBrowsers(); System.out.println("-------------------------------------"); System.out.println(siteResult.getSite().getUrl() + " saved per page: " + humanReadableByteCount(Math.round(siteResult.getTotalSavings()), true) + " pw:" + humanReadableByteCount( Math.round(siteResult.getTotalSavings() * siteResult.getSite().getPageViews()), true) + " unique:" + humanReadableByteCount( Math.round(siteResult.getTotalSavings() * siteResult.getSite().getUniqueBrowsers()), true)); System.out.println("Total page size:" + siteResult.getTotalSizeBytes() / 1000 + " kb"); for (RuleResult ruleResult : siteResult.getResults()) { System.out.println(ruleResult.getRule() + " " + ruleResult.getSavings() + " kb"); } } System.out.println("-------------------------------------"); System.out.println("Tested " + results.size() + " sites"); System.out .println("total pw:" + humanReadableByteCount(Math.round(totalPw), true) + " or in kb " + totalPw); System.out.println("total unique:" + humanReadableByteCount(Math.round(totalUnique), true) + " or in kb " + totalUnique); for (String rule : statistics.keySet()) { DescriptiveStatistics stats = statistics.get(rule); System.out.println(rule + " median save:" + stats.getPercentile(50) + " max save:" + stats.getMax()); } List<SiteResult> toplist = new ArrayList<SiteResult>(); toplist.addAll(results); Collections.sort(toplist); System.out.println("-------------------------------------"); System.out.println("TopList (kb):"); for (int i = 0; i < (toplist.size() < TOPLIST_ITEMS ? toplist.size() : TOPLIST_ITEMS); i++) System.out.println(toplist.get(i).getSite().getUrl() + " " + Math.round(toplist.get(i).getTotalSavings() * 100) / 100.0d); System.out.println("-------------------------------------"); System.out.println("BottomList (kb):"); for (int i = 1; i < (toplist.size() < TOPLIST_ITEMS ? toplist.size() : TOPLIST_ITEMS) + 1; i++) System.out.println(toplist.get(toplist.size() - i).getSite().getUrl() + " " + Math.round(toplist.get(toplist.size() - i).getTotalSavings() * 100) / 100.0d); Collections.sort(toplist, new SavingsPercentageComparator()); System.out.println("-------------------------------------"); System.out.println("TopList %:"); for (int i = 0; i < (toplist.size() < TOPLIST_ITEMS ? toplist.size() : TOPLIST_ITEMS); i++) System.out.println(toplist.get(i).getSite().getUrl() + " " + Math.round(toplist.get(i).getSavingsPercentage() * 100) / 100.0d); System.out.println("-------------------------------------"); System.out.println("BottomList %:"); for (int i = 1; i < (toplist.size() < TOPLIST_ITEMS ? toplist.size() : TOPLIST_ITEMS) + 1; i++) System.out.println(toplist.get(toplist.size() - i).getSite().getUrl() + " " + Math.round(toplist.get(toplist.size() - i).getSavingsPercentage() * 100) / 100.0d); System.out.println("-------------------------------------"); System.out.println("TopList most savings:"); Collections.sort(toplist, new TotalSavingsComparator()); for (int i = 1; i < (toplist.size() < TOPLIST_ITEMS ? toplist.size() : TOPLIST_ITEMS) + 1; i++) System.out .println(toplist.get(toplist.size() - i).getSite().getUrl() + " " + humanReadableByteCount( Math.round(toplist.get(toplist.size() - i).getTotalSavings() * toplist.get(toplist.size() - i).getSite().getUniqueBrowsers()), true)); System.out.println("-------------------------------------"); System.out.println("TopList largest sites:"); Collections.sort(toplist, new PageSizeComparator()); for (int i = 1; i < (toplist.size() < TOPLIST_ITEMS ? toplist.size() : TOPLIST_ITEMS) + 1; i++) System.out.println(toplist.get(toplist.size() - i).getSite().getUrl() + " " + humanReadableByteCount( Math.round(toplist.get(toplist.size() - i).getTotalSizeBytes() / 1000), true)); }
From source file:io.yields.math.concepts.operator.SmoothnessTest.java
@Spec(name = "quadratic data - first order smoothness", functional = SmoothnessTest.QuadraticData.class) public void testQuadratic_linearSmoothness(FunctionalContext<List<Tuple>> context) { //first order will not match DescriptiveStatistics stats = new Smoothness(1).apply(context.evaluate()); assertThat(stats.getMin()).isGreaterThan(0); assertThat(stats.getMax()).isLessThan(1); assertThat(stats.getMean()).isLessThan(.5); }
From source file:io.hops.leaderElection.experiments.ExperimentDriver.java
public void writeMessageToFile(int numProcesses, DescriptiveStatistics failOverStats, DescriptiveStatistics tpStats) throws IOException { PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("summary.log", true))); out.println(numProcesses + " " + tpStats.getN() + " " + tpStats.getMin() + " " + tpStats.getMax() + " " + tpStats.getMean() + " " + tpStats.getStandardDeviation() + " " + (tpStats.getStandardDeviation() / Math.sqrt(tpStats.getN())) + " " + failOverStats.getN() + " " + failOverStats.getMin() + " " + failOverStats.getMax() + " " + failOverStats.getMean() + " " + failOverStats.getStandardDeviation() + " " + (failOverStats.getStandardDeviation() / Math.sqrt(failOverStats.getN()))); out.close();// w ww . ja v a2 s . co m }
From source file:io.hops.experiments.stats.TransactionStatsCumulative.java
private void writeStats(BufferedWriter writer, String transaction, String[] columns, File depthDir, int key) throws IOException { writer.write(key + " "); for (String cache : RESOLVING_CACHES) { File cacheDir = new File(depthDir, cache); Map<String, DescriptiveStatistics> stats = null; Map<String, DescriptiveStatistics> statsResolving = null; if (cacheDir.exists()) { stats = TransactionStatsAggregator.aggregate(new File(cacheDir, HOPSSTATS), transaction); }//from ww w. j a v a 2s .c om if (isResolvingCache(cache)) { statsResolving = TransactionStatsAggregator.aggregate(new File(cacheDir, RESOLVING_CACHE_STATS), "GET"); } if (stats != null) { for (String col : columns) { DescriptiveStatistics st = stats.get(col); writer.write(st.getMin() + " " + st.getMean() + " " + st.getMax() + " "); } } if (statsResolving != null) { for (String col : RESOLVING_CACHE_COLUMNS) { DescriptiveStatistics st = statsResolving.get(col); writer.write(st.getMin() + " " + st.getMean() + " " + st.getMax() + " "); } } } writer.newLine(); }
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 www . j ava 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:cc.kave.commons.pointsto.evaluation.TimeEvaluation.java
public void exportResults(Path outputDir, ResultExporter exporter) throws IOException { Function<Double, String> format = number -> String.format(Locale.US, "%.3f", number); exporter.export(outputDir.resolve("TimeStatistics.txt"), analysisStatistics.entrySet().stream().map(entry -> { DescriptiveStatistics stats = entry.getValue(); return new String[] { entry.getKey(), format.apply(stats.getMin()), format.apply(stats.getStandardDeviation()), format.apply(stats.getMean()), format.apply(stats.getMax()) }; }));//from w w w.j a v a 2 s .c o m exporter.export(outputDir.resolve("StmtCountTimes.txt"), analysisTimes.stream() .map(entry -> new String[] { entry.analysisName, entry.contextType.getFullName(), Integer.toString(entry.numStmts), format.apply(entry.time) })); }
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 ww .j ava 2 s . c om 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()); }