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

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

Introduction

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

Prototype

public SummaryStatistics() 

Source Link

Document

Construct a SummaryStatistics instance

Usage

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);/*from   www  .  ja v  a 2s. c  om*/
    }

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

From source file:com.griddynamics.jagger.util.statistics.StatisticsCalculator.java

public StatisticsCalculator() {
    summaryStatistics = new SummaryStatistics();
    percentilesProcessor = new PercentilesProcessor();
}

From source file:hmp.Read.java

private void addToHash(HashMap<String, SummaryStatistics> hash, String key, double value) {
    if (hash.containsKey(key)) {
        SummaryStatistics stat = hash.get(key);
        stat.addValue(value);//from   w w w  .  j  av a2  s .  co  m
    } else {
        SummaryStatistics stat = new SummaryStatistics();
        stat.addValue(value);
        hash.put(key, stat);
    }
}

From source file:de.tudarmstadt.ukp.dkpro.core.decompounding.ranking.FrequencyGeometricMeanRanker.java

/**
 * Calculates the weight for a split/*w  w  w  .jav  a  2 s  .  c om*/
 */
private double calcRank(DecompoundedWord aSplit) {
    SummaryStatistics stats = new SummaryStatistics();
    for (Fragment elem : aSplit.getSplits()) {
        stats.addValue(freq(elem).doubleValue());
    }
    return stats.getGeometricMean();
}

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  www.j a v  a2s.  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:boa.aggregators.VarianceAggregator.java

/** {@inheritDoc} */
@Override//  w  w  w  . ja  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.getVariance());
}

From source file:boa.aggregators.StDevAggregator.java

/** {@inheritDoc} */
@Override/* w  w w  . j  a v a 2 s  .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:geogebra.kernel.AlgoNormalQuantilePlot.java

private GeoSegment getQQLineSegment() {

    SummaryStatistics stats = new SummaryStatistics();
    for (int i = 0; i < sortedData.length; i++) {
        stats.addValue(sortedData[i]);/* ww  w  . j a  v a  2  s  .  co 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

/**
 * @param key the name of package.class.method
 * @return the Statistics of the method//from ww w .j a v  a2s  .c  o m
 */
private SummaryStatistics getStatistics(final String key) {
    SummaryStatistics statistics = statisticsMap.get(key);
    if (statistics == null || statistics.getN() >= (long) this.maxValues) {
        statistics = new SummaryStatistics();
        statisticsMap.put(key, statistics);
    }
    return statistics;
}

From source file:com.netflix.curator.framework.recipes.queue.TestQueueSharder.java

@Test
public void testDistribution() throws Exception {
    final int threshold = 100;
    final int factor = 10;

    Timing timing = new Timing();
    CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(),
            timing.connection(), new RetryOneTime(1));
    QueueSharder<String, DistributedQueue<String>> sharder = null;
    try {/*from   w w w .j ava 2  s .com*/
        client.start();

        final CountDownLatch latch = new CountDownLatch(1);
        QueueConsumer<String> consumer = new QueueConsumer<String>() {
            @Override
            public void consumeMessage(String message) throws Exception {
                latch.await();
            }

            @Override
            public void stateChanged(CuratorFramework client, ConnectionState newState) {
            }
        };
        QueueAllocator<String, DistributedQueue<String>> distributedQueueAllocator = makeAllocator(consumer);
        QueueSharderPolicies policies = QueueSharderPolicies.builder().newQueueThreshold(threshold)
                .thresholdCheckMs(1).build();
        sharder = new QueueSharder<String, DistributedQueue<String>>(client, distributedQueueAllocator,
                "/queues", "/leader", policies);
        sharder.start();

        for (int i = 0; i < (factor * threshold); ++i) {
            sharder.getQueue().put(Integer.toString(i));
            Thread.sleep(5);
        }
        timing.forWaiting().sleepABit();

        SummaryStatistics statistics = new SummaryStatistics();
        for (String path : sharder.getQueuePaths()) {
            int numChildren = client.checkExists().forPath(path).getNumChildren();
            Assert.assertTrue(numChildren > 0);
            Assert.assertTrue(numChildren >= (threshold * .1));
            statistics.addValue(numChildren);
        }
        latch.countDown();

        Assert.assertTrue(statistics.getMean() >= (threshold * .9));
    } finally {
        timing.sleepABit(); // let queue clear
        Closeables.closeQuietly(sharder);
        Closeables.closeQuietly(client);
    }
}