List of usage examples for org.apache.commons.math3.stat.descriptive DescriptiveStatistics getStandardDeviation
public double getStandardDeviation()
From source file:net.adamjak.thomas.graph.application.commons.StatisticsUtils.java
public static double getConfidenceInterval(DescriptiveStatistics inputStatistics, NormCritical uAlpha) throws IllegalArgumentException { if (inputStatistics == null || uAlpha == null) throw new IllegalArgumentException("Params inputStatistics or uAlpha can not be null!"); return (inputStatistics.getStandardDeviation() * uAlpha.getCriticalValue()) / Math.sqrt(inputStatistics.getValues().length); }
From source file:knop.psfj.utils.MathUtils.java
/** * Format statistics./*from w w w . j a v a 2 s . c o 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:cc.kave.commons.pointsto.evaluation.runners.ProjectStoreRunner.java
private static void countUsages(Collection<ICoReTypeName> types, ProjectUsageStore store) throws IOException { int totalNumberOfProjects = store.getNumberOfProjects(); for (ICoReTypeName type : types) { int numProjects = store.getProjects(type).size(); if (numProjects < 10) { continue; }//from w w w . ja va 2 s. c o m Map<ProjectIdentifier, Integer> usageCounts = store.getNumberOfUsagesPerProject(type); DescriptiveStatistics statistics = new DescriptiveStatistics(); usageCounts.values().forEach(count -> statistics.addValue(count)); for (int i = 0; i < totalNumberOfProjects - numProjects; ++i) { statistics.addValue(0); } System.out.printf(Locale.US, "%s: %.1f\n", CoReNames.vm2srcQualifiedType(type), statistics.getStandardDeviation()); } }
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);/*from w ww .j a va2 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: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 w w w. java 2 s.com } return outputStatistic; }
From source file:io.hops.experiments.stats.TransactionStatsAggregator.java
public static Map<String, DescriptiveStatistics> aggregate(File statsFile, String headerPattern, String transaction, boolean printSummary) throws IOException { if (!statsFile.exists()) return null; transaction = transaction.toUpperCase(); BufferedReader reader = new BufferedReader(new FileReader(statsFile)); String tx = reader.readLine(); String[] headers = null;//from w ww .j ava2s. c o m Map<Integer, DescriptiveStatistics> statistics = Maps.newHashMap(); if (tx != null) { headers = tx.split(","); for (int i = 1; i < headers.length; i++) { String h = headers[i].toUpperCase(); if (h.contains(headerPattern) || headerPattern.equals(ALL)) { statistics.put(i, new DescriptiveStatistics()); } } } int txCount = 0; while ((tx = reader.readLine()) != null) { if (tx.startsWith(transaction) || transaction.equals(ALL)) { txCount++; String[] txStats = tx.split(","); if (txStats.length == headers.length) { for (Map.Entry<Integer, DescriptiveStatistics> e : statistics.entrySet()) { e.getValue().addValue(Double.valueOf(txStats[e.getKey()])); } } } } reader.close(); if (headers == null) return null; if (printSummary) { System.out.println("Transaction: " + transaction + " " + txCount); List<Integer> keys = new ArrayList<Integer>(statistics.keySet()); Collections.sort(keys); for (Integer i : keys) { DescriptiveStatistics stats = statistics.get(i); if (stats.getMin() == 0 && stats.getMax() == 0) { continue; } System.out.println(headers[i]); System.out.println("Min " + stats.getMin() + " Max " + stats.getMax() + " Avg " + stats.getMean() + " Std " + stats.getStandardDeviation()); } } Map<String, DescriptiveStatistics> annotatedStats = Maps.newHashMap(); for (Map.Entry<Integer, DescriptiveStatistics> e : statistics.entrySet()) { annotatedStats.put(headers[e.getKey()].trim(), e.getValue()); } return annotatedStats; }
From source file:main.java.metric.Metric.java
public static double getCVServerData(Cluster cluster) { DescriptiveStatistics server_data = new DescriptiveStatistics(); for (Server server : cluster.getServers()) server_data.addValue(server.getServer_total_data()); double c_v = server_data.getStandardDeviation() / server_data.getMean(); return c_v;//www .jav a2 s. co m }
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;//from w ww.j a v a 2 s . com 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:de.uniulm.omi.cloudiator.axe.aggregator.utils.Calc.java
public static Double STD(List<Double> values) { DescriptiveStatistics ds = transform(values); return ds.getStandardDeviation(); }
From source file:main.java.metric.Metric.java
public static double getCVServerData(Cluster cluster, Transaction tr) { DescriptiveStatistics server_data = new DescriptiveStatistics(); for (Entry<Integer, HashSet<Integer>> entry : tr.getTr_serverSet().entrySet()) { server_data.addValue(entry.getValue().size()); }//from w w w . ja va 2 s . c om double c_v = server_data.getStandardDeviation() / server_data.getMean(); return c_v; }