/** * Generates a text report displaying univariate statistics from values * that have been added. Each statistic is displayed on a separate * line. * * @return String with line feeds displaying statistics */ @Override public String toString() { StringBuilder outBuffer = new StringBuilder(); String endl = "\n"; outBuffer.append("DescriptiveStatistics:").append(endl); outBuffer.append("n: ").append(getN()).append(endl); outBuffer.append("min: ").append(getMin()).append(endl); outBuffer.append("max: ").append(getMax()).append(endl); outBuffer.append("mean: ").append(getMean()).append(endl); outBuffer.append("std dev: ").append(getStandardDeviation()) .append(endl); try { // No catch for MIAE because actual parameter is valid below outBuffer.append("median: ").append(getPercentile(50)).append(endl); } catch (MathIllegalStateException ex) { outBuffer.append("median: unavailable").append(endl); } outBuffer.append("skewness: ").append(getSkewness()).append(endl); outBuffer.append("kurtosis: ").append(getKurtosis()).append(endl); return outBuffer.toString(); }
static SimpleStats from(DescriptiveStatistics stats) { SimpleStats ss = new SimpleStats(); ss._min = stats.getMin(); ss._max = stats.getMax(); ss._mean = stats.getMean(); ss._std = stats.getStandardDeviation(); ss._median = stats.getPercentile(50); return ss; }
@Override public String toString() { MoreObjects.ToStringHelper helper = MoreObjects.toStringHelper(this) .add("numResults", stats.getN()) .add("minTime", stats.getMin()) .add("meanTime", stats.getMean()) .add("maxTime", stats.getMax()) .add("25th", stats.getPercentile(25)) .add("50th", stats.getPercentile(50)) .add("75th", stats.getPercentile(75)) .add("90th", stats.getPercentile(90)) .add("95th", stats.getPercentile(95)) .add("99th", stats.getPercentile(99)) .add("99.9th", stats.getPercentile(99.9)) .add("99.99th", stats.getPercentile(99.99)) .add("traces", traces); return helper.toString(); } }
@Override public double getPercentile(double p) { return descStats.getPercentile(p); }
public String getPercentile() { return formatter.apply(stats.getPercentile(percentile)); }
public static void summary(String title, DescriptiveStatistics statistics, PrintStream pw, boolean meanOnly) { if(meanOnly) { pw.println(title + ": " + "\n\tMean: " + statistics.getMean() ); } else { pw.println(title + ": " + "\n\tMean: " + statistics.getMean() + "\n\tMin: " + statistics.getMin() + "\n\t1th: " + statistics.getPercentile(1) + "\n\t5th: " + statistics.getPercentile(5) + "\n\t10th: " + statistics.getPercentile(10) + "\n\t25th: " + statistics.getPercentile(25) + "\n\t50th: " + statistics.getPercentile(50) + "\n\t90th: " + statistics.getPercentile(90) + "\n\t95th: " + statistics.getPercentile(95) + "\n\t99th: " + statistics.getPercentile(99) + "\n\tMax: " + statistics.getMax() + "\n\tStdDev: " + statistics.getStandardDeviation() ); } } public void printDepthSummary(int depth, boolean meanOnly) {
public static String describe(DescriptiveStatistics stats, Double[] percentiles){ StringBuilder sb = new StringBuilder(); sb.append(String.format("round: mean of %dms [+-%d], measured %d rounds;\n", (long)stats.getMean(), (long)stats.getStandardDeviation(), stats.getN() )); sb.append("\tMin - " + (long)stats.getMin() + "\n"); for(double pctile : percentiles) { sb.append("\t" + pctile + " - " + stats.getPercentile(pctile) + "\n"); } sb.append("\tMax - " + (long)stats.getMax()); return sb.toString(); }
public static double getMedianHighOpenSpread(String symbol, int days) throws Exception { YahooQuoteFetcher yahooFetcher = new YahooQuoteFetcher(); String quoteStr = yahooFetcher.fetchQuotes(symbol, days, 60*60*24); List<Quote> dailyQuoteList = yahooFetcher.parseQuotes(quoteStr, 60*60*24); DescriptiveStatistics stats = new DescriptiveStatistics(); for(Quote quote : dailyQuoteList) { stats.addValue(quote.getHigh().subtract(quote.getOpen()).doubleValue()); } return stats.getPercentile(50); }
public double[] getDIndexBounds(){ double[] bounds = new double[2]; bounds[0] = stats.getPercentile(27); bounds[1] = stats.getPercentile(73); return bounds; }
@Override public double getQuantile(double quantile) { return descriptiveStatistics.getPercentile(quantile * 100); }
/** * Returns an estimate for the requested percentile of the stored values. * * @param percentile * the requested percentile (scaled from 0 - 100) * @return Returns an estimate for the requested percentile of the stored * values. */ public double getOkPercentile(double percentile) { return okResponsesStats.getPercentile(percentile); }
/** * Returns an estimate for the requested percentile of the stored values. * * @param percentile * the requested percentile (scaled from 0 - 100) * @return Returns an estimate for the requested percentile of the stored * values. */ public double getKoPercentile(double percentile) { return koResponsesStats.getPercentile(percentile); }
/** * Returns an estimate for the requested percentile of the stored values. * * @param percentile * the requested percentile (scaled from 0 - 100) * @return Returns an estimate for the requested percentile of the stored * values. */ public double getAllPercentile(double percentile) { return pctResponseStats.getPercentile(percentile); }
/** * Compute Median Absolute Error * * @return MedAE */ private double getMedianAbsoluteError() { return goldSubtractPredictionAbsoluteStats.getPercentile(50); }
/** * Gets the median from a list of numbers. * * @param list the list of numbers * @return the median */ public static double median(final List<Double> list) { return getStatistics(list).getPercentile(50); }
/** * Gets the median from an array of numbers. * * @param list the array of numbers * * @return the median */ public static double median(final double[] list) { return getStatistics(list).getPercentile(50); }
public static Double PERCENTILE(List<Double> values) { //TODO this semantics has to be defined better Double p = values.get(0); values.remove(0); DescriptiveStatistics ds = transform(values); return ds.getPercentile(p); }
private static PerformanceResultsPublisherClient.PerformanceTestResult runPerformanceTest(TestPluginModuleStorageClient testPluginModuleStorageClient, PluginModulePerformanceTest performanceTest) throws Exception { final DescriptiveStatistics statistics = new DescriptiveStatistics(); final String deserializerIdentifier = performanceTest.getDeserializerIdentifier(); for (int i = 0; i < ITERATIONS; i++) { statistics.addValue(testPluginModuleStorageClient.testDeserializerByIdentifier(deserializerIdentifier).get("totalElapsedTimeMs").getDouble()); log.info("Moving median " + i + ": " + statistics.getPercentile(50)); } final double medianTimeMs = statistics.getPercentile(50); log.info("Median time for " + deserializerIdentifier + " with " + PLUGIN_MODULES + " modules: " + medianTimeMs + "ms"); final String assertionReason = "Deserializing " + deserializerIdentifier + " took too much time. More than " + performanceTest.maximumTimeMsForOneHundredModules() + "ms."; Assert.assertThat(assertionReason, medianTimeMs, Matchers.lessThanOrEqualTo(performanceTest.maximumTimeMsForOneHundredModules())); return new PerformanceResultsPublisherClient.PerformanceTestResult(deserializerIdentifier, medianTimeMs, statistics.getPercentile(99)); }
DescriptiveStatistics ds = new DescriptiveStatistics(); ds.addValue(10); ds.addValue(10); ds.addValue(30); // median is basically 50th percentile System.out.println(ds.getPercentile(50)); // displays 10
static SimpleStats from(DescriptiveStatistics stats) { SimpleStats ss = new SimpleStats(); ss._min = stats.getMin(); ss._max = stats.getMax(); ss._mean = stats.getMean(); ss._std = stats.getStandardDeviation(); ss._median = stats.getPercentile(50); return ss; }