protected void printSegmentAssignment(Map<String, Map<String, String>> mapping) throws Exception { LOGGER.info(JsonUtils.objectToPrettyString(mapping)); Map<String, List<String>> serverToSegmentMapping = new TreeMap<>(); for (String segment : mapping.keySet()) { Map<String, String> serverToStateMap = mapping.get(segment); for (String server : serverToStateMap.keySet()) { if (!serverToSegmentMapping.containsKey(server)) { serverToSegmentMapping.put(server, new ArrayList<>()); } serverToSegmentMapping.get(server).add(segment); } } DescriptiveStatistics stats = new DescriptiveStatistics(); for (String server : serverToSegmentMapping.keySet()) { List<String> list = serverToSegmentMapping.get(server); LOGGER.info("server " + server + " has " + list.size() + " segments"); stats.addValue(list.size()); } LOGGER.info("Segment Distrbution stat"); LOGGER.info(stats.toString()); }
public void report() { synchronized (_statistics) { LOGGER.info("--------------------------------------------------------------------------------"); LOGGER.info("{}:", _name); LOGGER.info(_statistics.toString()); LOGGER.info("10th percentile: {}", _statistics.getPercentile(10.0)); LOGGER.info("25th percentile: {}", _statistics.getPercentile(25.0)); LOGGER.info("50th percentile: {}", _statistics.getPercentile(50.0)); LOGGER.info("90th percentile: {}", _statistics.getPercentile(90.0)); LOGGER.info("95th percentile: {}", _statistics.getPercentile(95.0)); LOGGER.info("99th percentile: {}", _statistics.getPercentile(99.0)); LOGGER.info("99.9th percentile: {}", _statistics.getPercentile(99.9)); LOGGER.info("--------------------------------------------------------------------------------"); } }
@Override public String getSummaryReport() { final StringBuilder outBuffer = new StringBuilder(); final DescriptiveStatistics ds = computeStats(); outBuffer.append("Aggregate P@" + N + " Statistics:\n"); outBuffer.append(String.format("%-15s\t%6d\n", "num_q", ds.getN())); outBuffer.append(String.format("%-15s\t%6.4f\n", "min", ds.getMin())); outBuffer.append(String.format("%-15s\t%6.4f\n", "max", ds.getMax())); outBuffer.append(String.format("%-15s\t%6.4f\n", "mean", ds.getMean())); outBuffer.append(String.format("%-15s\t%6.4f\n", "std dev", ds.getStandardDeviation())); outBuffer.append(String.format("%-15s\t%6.4f\n", "median", ds.getPercentile(50))); outBuffer.append(String.format("%-15s\t%6.4f\n", "skewness", ds.getSkewness())); outBuffer.append(String.format("%-15s\t%6.4f\n", "kurtosis", ds.getKurtosis())); return outBuffer.toString(); }
/** * Compute the current aggregate statistics of the * accumulated results. * * @return the current aggregate statistics */ public AggregateStatistics computeStatistics() { DescriptiveStatistics accuracy = new DescriptiveStatistics(); DescriptiveStatistics errorRate = new DescriptiveStatistics(); for (CMResult<CLASS> result : matrices) { ConfusionMatrix<CLASS> m = result.getMatrix(); accuracy.addValue(m.getAccuracy()); errorRate.addValue(m.getErrorRate()); } AggregateStatistics s = new AggregateStatistics(); s.meanAccuracy = accuracy.getMean(); s.stddevAccuracy = accuracy.getStandardDeviation(); s.meanErrorRate = errorRate.getMean(); s.stddevErrorRate = errorRate.getStandardDeviation(); return s; }
/** * Get the mean, variance and the third central moment from an array of doubles. * @param distribution the array of doubles * @return a float of length three. Encodes the mean, the variance and the * third central moment */ private static float[] getThreeMoments(double[] distribution) { DescriptiveStatistics descriptiveStatistics = new DescriptiveStatistics(); for (double val : distribution){ descriptiveStatistics.addValue(val); } float[] outVals = new float[3]; outVals[0] = (float) descriptiveStatistics.getMean(); outVals[1] = (float) descriptiveStatistics.getVariance(); outVals[2] = (float) descriptiveStatistics.getSkewness(); return outVals; }
DescriptiveStatistics oStats = new DescriptiveStatistics(); DescriptiveStatistics sStats = new DescriptiveStatistics(); DescriptiveStatistics bStats = new DescriptiveStatistics(); System.out.printf("%s %s %s %s%n", padString(" mean", 25), padDouble(sStats.getMean()), padDouble(bStats.getMean()), padDouble(oStats.getMean()) ); System.out.printf("%s %s %s %s%n", padString(" median", 25), padDouble(sStats.getPercentile(50.0)), padDouble(bStats.getPercentile(50.0)), padDouble(oStats.getPercentile(50.0)) ); System.out.printf("%s %s %s %s%n", padString(" deviation", 25), padDouble(sStats.getStandardDeviation()), padDouble(bStats.getStandardDeviation()), padDouble(oStats.getStandardDeviation()) ); padDouble(sStats.getVariance()), padDouble(bStats.getVariance()), padDouble(oStats.getVariance()) );
public void addValue(double value) { synchronized (_statistics) { _statistics.addValue(value); } }
public static String testSpeed(HashMethod hm, List<List<byte[]>> hashData, int hashesPerRound, int m, int k, int rounds) { DescriptiveStatistics speed = new DescriptiveStatistics(); HashFunction hf = hm.getHashFunction(); int hashRounds = hashesPerRound / k; Random r = new Random(); for (int i = 0; i < rounds; i++) { List<byte[]> data = hashData.get(i); long start_hash = System.nanoTime(); for (int i1 = 0; i1 < hashRounds; i1++) { int[] hashes = hf.hash(data.get(i1), m, k); } long end_hash = System.nanoTime(); speed.addValue((1.0 * end_hash - start_hash) / 1000000); } System.out.println("HashMethod : " + hm + ", " + " hashes = " + hashesPerRound + ", size = " + m + ", hashes = " + k + ", rounds = " + rounds); //System.out.println(speed); return Arrays.toString(speed.getValues()).replace("[", "{").replace("]", "}"); }
public FailureDetector(long minimumSamples, int windowSize, String distribution) { descriptiveStatistics = new DescriptiveStatistics(windowSize); this.minimumSamples = minimumSamples; this.distribution = distribution; }
/** * Retrieve average response time of the <code>ResponsetimeSample</code> instances. * * @return the average responsetime of all samples */ public final double getAverage() { return responsetimeStats.getMean(); }
public void addValue(double value) { switch (currentStrategy) { case HEURISTIC: adaptiveHistogram.addValue(value); break; case EXACT: descriptiveStatistics.addValue(value); break; case AUTO: if(descriptiveStatistics.getN() >= exactProcessorMaxCapacity) { adaptiveHistogram = new AdaptiveHistogram(); double[] values = descriptiveStatistics.getValues(); for(int i = 0; i < values.length; i++) { adaptiveHistogram.addValue(values[i]); } adaptiveHistogram.addValue(value); currentStrategy = EstimationStrategy.HEURISTIC; } else { descriptiveStatistics.addValue(value); } } }
/** * Calculate the 95 % fractile of the <code>ResponsetimeSample</code> instances. * * @return the 95% fractile of all responsetimes */ public final double getPercentile95() { return responsetimeStats.getPercentile( PERCENTILE_95 ); }
/** * Get the max of the series. * * @return max of the series */ public double getMax() { return data.getMax(); }
/** * Get the min of x values. * * @return x values min */ public double getXMin() { return xData.getMin(); }
static void printTable(TreeBasedTable<Integer, Integer, DescriptiveStatistics> table) { System.out.printf("\t%s%n", StringUtils.join(table.columnKeySet(), "\t\t\t")); for (Map.Entry<Integer, Map<Integer, DescriptiveStatistics>> entry : table.rowMap() .entrySet()) { System.out.printf("%s\t", entry.getKey()); for (DescriptiveStatistics ds : entry.getValue().values()) { System.out.printf("%.2f\t%2f\t%d\t", ds.getMean(), ds.getStandardDeviation(), ds.getN()); } System.out.println(); } }
public double getPercentile(int percentage) { if (_stats.getN() == 0) { return 0; } return _stats.getPercentile(percentage * 1.0); } }
/** * Default constructor. * * @param name * name of this measure */ public ChartSeries1DMeasure(String name) { super(name); this.data = new DescriptiveStatistics(); this.data.setWindowSize(DEFAULT_WINDOW_SIZE); }
/** * Returns the standard deviation of the available values. * @return The standard deviation, Double.NaN if no values have been added * or 0.0 for a single value set. */ public double getStandardDeviation() { double stdDev = Double.NaN; if (getN() > 0) { if (getN() > 1) { stdDev = Math.sqrt(getVariance()); } else { stdDev = 0.0; } } return (stdDev); }