Example usage for org.apache.commons.math.stat.descriptive SummaryStatistics getMean

List of usage examples for org.apache.commons.math.stat.descriptive SummaryStatistics getMean

Introduction

In this page you can find the example usage for org.apache.commons.math.stat.descriptive SummaryStatistics getMean.

Prototype

public double getMean() 

Source Link

Document

Returns the mean of the values that have been added.

Usage

From source file:com.netflix.dyno.connectionpool.impl.lb.CircularListTest.java

private static double checkValues(List<Integer> values) {

    System.out.println("Values: " + values);
    SummaryStatistics ss = new SummaryStatistics();
    for (int i = 0; i < values.size(); i++) {
        ss.addValue(values.get(i));/*from w w w  . j a v  a 2s .c o m*/
    }

    double mean = ss.getMean();
    double stddev = ss.getStandardDeviation();

    double p = ((stddev * 100) / mean);
    System.out.println("Percentage diff: " + p);

    Assert.assertTrue("" + p + " " + values, p < 0.1);
    return p;
}

From source file:com.userweave.module.methoden.rrt.page.report.MeanAndStdDeviation.java

public MeanAndStdDeviation(List<Double> values) {
    SummaryStatistics stats = new SummaryStatistics();
    for (Double value : values) {
        stats.addValue(value);/*  w  w w.j  a va 2  s  .  c o m*/
    }

    this.mean = stats.getMean();
    this.stdDeviation = stats.getStandardDeviation();
}

From source file:com.userweave.module.methoden.questionnaire.page.report.question.AnswerStatistics.java

public Double getRatingMean(T object) {
    SummaryStatistics summaryStatistics = getSummaryStatistics(object);
    if (summaryStatistics != null) {
        return summaryStatistics.getMean();
    } else {/*from  ww w .  j ava 2 s.  c  om*/
        return 0d;
    }
}

From source file:com.userweave.domain.service.impl.GeneralStatisticsImpl.java

public GeneralStatisticsImpl(SummaryStatistics stats, Integer overallStarted, Integer started,
        Integer finished) {/*from ww  w  .  ja v a 2s .  c o m*/
    this(overallStarted, started, finished, stats == null ? 0L : Double.valueOf(stats.getMean()).longValue(),
            stats == null ? 0L : stats.getStandardDeviation());
}

From source file:geogebra.kernel.AlgoNormalQuantilePlot.java

private GeoSegment getQQLineSegment() {

    SummaryStatistics stats = new SummaryStatistics();
    for (int i = 0; i < sortedData.length; i++) {
        stats.addValue(sortedData[i]);//from   w ww .ja v  a2s .  c om
    }
    double sd = stats.getStandardDeviation();
    double mean = stats.getMean();
    double min = stats.getMin();
    double max = stats.getMax();

    // qq line: y = (1/sd)x - mean/sd 

    GeoPoint startPoint = new GeoPoint(cons);
    startPoint.setCoords(min, (min / sd) - mean / sd, 1.0);
    GeoPoint endPoint = new GeoPoint(cons);
    endPoint.setCoords(max, (max / sd) - mean / sd, 1.0);
    GeoSegment seg = new GeoSegment(cons, startPoint, endPoint);
    seg.calcLength();

    return seg;
}

From source file:geogebra.common.kernel.statistics.AlgoNormalQuantilePlot.java

private GeoSegment getQQLineSegment() {

    SummaryStatistics stats = new SummaryStatistics();
    for (int i = 0; i < sortedData.length; i++) {
        stats.addValue(sortedData[i]);/*www. ja  v a2 s  . c o m*/
    }
    double sd = stats.getStandardDeviation();
    double mean = stats.getMean();
    double min = stats.getMin();
    double max = stats.getMax();

    // qq line: y = (1/sd)x - mean/sd

    GeoPoint startPoint = new GeoPoint(cons);
    startPoint.setCoords(min, (min / sd) - mean / sd, 1.0);
    GeoPoint endPoint = new GeoPoint(cons);
    endPoint.setCoords(max, (max / sd) - mean / sd, 1.0);
    GeoSegment seg = new GeoSegment(cons, startPoint, endPoint);
    seg.calcLength();

    return seg;
}

From source file:de.escidoc.core.om.performance.Statistics.java

/**
 * @return the statistics of all measured methods.
 *///from   w w  w . ja v a  2  s .  com
@ManagedAttribute(description = "Get all currently available statistics")
public String getKeys() {
    final StringBuilder b = new StringBuilder();
    for (final String key : this.statisticsMap.keySet()) {
        final SummaryStatistics s = getStatistics(key);
        if (s != null) {
            b.append(key).append(", #:").append(s.getN()).append(", min (ms):").append((long) s.getMin())
                    .append(", max (ms):").append((long) s.getMax()).append(", mean (ms):")
                    .append((long) s.getMean()).append(", stddev (ms):").append((long) s.getStandardDeviation())
                    .append(", total (ms):").append((long) s.getSum()).append('\n');
        }
    }
    System.gc();
    return b.toString();
}

From source file:com.vmware.upgrade.progress.impl.SimpleAggregatingProgressReporter.java

private int calculateProgress() {
    final SummaryStatistics childProgress = new SummaryStatistics();
    for (final PropagatingListener listener : childListeners) {
        childProgress.addValue(listener.getCurrentProgressReport().getProgress());
    }/*from   w  w w.  j av  a 2 s .  c  o  m*/

    final int roundedProgress = (int) Math.round(childProgress.getMean());
    return roundedProgress;
}

From source file:edu.scripps.fl.curves.plot.CurvePlot.java

protected YIntervalSeries getSeries(Map<Double, Collection<Double>> map, String description) {
    YIntervalSeries series = new YIntervalSeries(description);
    series.setDescription(description);/* ww w  . j  a  v a2  s  .c o  m*/
    for (Object o : map.keySet()) {
        SummaryStatistics stats = new SummaryStatistics();
        Collection<Double> values = (Collection<Double>) map.get(o);
        for (Double d : values)
            stats.addValue(d);
        double avg = stats.getMean();
        double stddev = stats.getStandardDeviation();
        //         System.out.println(String.format("Adding %e\t%.2f\t%.2f",o, avg, stddev));
        series.add((Double) o, avg, avg - stddev, avg + stddev);
    }
    return series;
}

From source file:gsn.tests.performance.Queries.java

private String printStats(SummaryStatistics stats, String unit) {
    return new StringBuilder().append("sum:").append(format(stats.getSum())).append(", min:")
            .append(format(stats.getMin())).append(", max:").append(format(stats.getMax())).append(", mean:")
            .append(format(stats.getMean())).append(", var:").append(format(stats.getVariance())).append(" [")
            .append(unit).append("]").toString();
}