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

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

Introduction

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

Prototype

public double getStandardDeviation() 

Source Link

Document

Returns the standard deviation of the values that have been added.

Usage

From source file:com.yahoo.ycsb.measurements.OneMeasurementStatistics.java

/**
 * Calculates the 95% confidence interval. If less than 30 measurements where
 * recorded, 0.0 is returned.//from w w w  .  j  a v  a 2  s . c  om
 * 
 * @param summaryStatistics The statistics object holding the recorded values
 * @return The 95% confidence interval or 0 if summaryStatistics.getN() is
 * less than 30 
 */
public static double get95ConfidenceIntervalWidth(SummaryStatistics summaryStatistics) {
    double a = 1.960; // 95% confidence interval width for standard deviation
    return a * summaryStatistics.getStandardDeviation() / Math.sqrt(summaryStatistics.getN());
}

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));/*  ww  w. j  av a2 s  . 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.questionnaire.page.report.question.AnswerStatistics.java

public Double getRatingStandardDeviation(T object) {
    SummaryStatistics summaryStatistics = getSummaryStatistics(object);
    if (summaryStatistics != null) {
        return summaryStatistics.getStandardDeviation();
    } else {/* ww  w . j a  va2s  .co  m*/
        return null;
    }
}

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);// ww w .j  a v a 2 s  . co m
    }

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

From source file:com.netflix.curator.x.discovery.TestStrategies.java

@Test
public void testRandom() throws Exception {
    final int QTY = 10;
    final int ITERATIONS = 1000;

    TestInstanceProvider instanceProvider = new TestInstanceProvider(QTY, 0);
    ProviderStrategy<Void> strategy = new RandomStrategy<Void>();

    long[] counts = new long[QTY];
    for (int i = 0; i < ITERATIONS; ++i) {
        ServiceInstance<Void> instance = strategy.getInstance(instanceProvider);
        int id = Integer.parseInt(instance.getId());
        counts[id]++;/*from ww  w. j  av a 2  s  .co  m*/
    }

    SummaryStatistics statistic = new SummaryStatistics();
    for (int i = 0; i < QTY; ++i) {
        statistic.addValue(counts[i]);
    }
    Assert.assertTrue(statistic.getStandardDeviation() <= (QTY * 2), "" + statistic.getStandardDeviation()); // meager check for even distribution
}

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

public GeneralStatisticsImpl(SummaryStatistics stats, Integer overallStarted, Integer started,
        Integer finished) {/*  w ww  .j  ava 2  s . co  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  w w .ja  v  a 2  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: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]);//from   w  w  w  .j a v a 2s.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:boa.aggregators.StDevAggregator.java

/** {@inheritDoc} */
@Override/*  w ww.  j  a v a2s  .co  m*/
public void finish() throws IOException, InterruptedException {
    if (this.isCombining()) {
        String s = "";
        for (final Long key : map.keySet())
            s += key + ":" + map.get(key) + ";";
        this.collect(s, null);
        return;
    }

    final SummaryStatistics summaryStatistics = new SummaryStatistics();

    for (final Long key : map.keySet()) {
        final long count = map.get(key);
        for (long i = 0; i < count; i++)
            summaryStatistics.addValue(key);
    }

    this.collect(summaryStatistics.getStandardDeviation());
}

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

/**
 * @return the statistics of all measured methods.
 *///from  ww w .  ja v  a2 s .c o m
@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();
}