Example usage for org.apache.commons.math3.stat.descriptive DescriptiveStatistics getSum

List of usage examples for org.apache.commons.math3.stat.descriptive DescriptiveStatistics getSum

Introduction

In this page you can find the example usage for org.apache.commons.math3.stat.descriptive DescriptiveStatistics getSum.

Prototype

public double getSum() 

Source Link

Document

Returns the sum of the values that have been added to Univariate.

Usage

From source file:com.spotify.annoy.jni.base.Benchmark.java

private static void dispStats(List<Long> queryTime) {
    DescriptiveStatistics s = new DescriptiveStatistics();

    for (Long t : queryTime) {
        s.addValue(t);/*  w  ww  .j  a  v a2  s  .c o m*/
    }

    System.out.print(new StringBuilder().append(String.format("Total time:  %.5fs\n", s.getSum() / 1.e9))
            .append(String.format("Mean time:   %.5fs\n", s.getMean() / 1.e9))
            .append(String.format("Median time: %.5fs\n", s.getPercentile(.5) / 1.e9))
            .append(String.format("Stddev time: %.5fs\n", s.getStandardDeviation() / 1.e9))
            .append(String.format("Min time:    %.5fs\n", s.getMin() / 1.e9))
            .append(String.format("Max time:    %.5fs\n", s.getMax() / 1.e9)).toString());
}

From source file:com.github.aptd.simulation.core.statistic.local.CStatistic.java

/**
 * write data//from   www.  j  ava  2 s  . co  m
 *
 * @param p_writer writer instance
 * @param p_name section name
 * @param p_statistic statistic value
 */
private static void apply(final IWriter p_writer, final String p_name,
        final DescriptiveStatistics p_statistic) {
    p_writer.section(1, p_name);

    p_writer.value("geometricmean", p_statistic.getGeometricMean());
    p_writer.value("kurtosis", p_statistic.getKurtosis());
    p_writer.value("max", p_statistic.getMax());
    p_writer.value("min", p_statistic.getMin());
    p_writer.value("mean", p_statistic.getMean());
    p_writer.value("count", p_statistic.getN());
    p_writer.value("25-percentile", p_statistic.getPercentile(0.25));
    p_writer.value("75-percentile", p_statistic.getPercentile(0.75));
    p_writer.value("populationvariance", p_statistic.getPopulationVariance());
    p_writer.value("quadraticmean", p_statistic.getQuadraticMean());
    p_writer.value("standdeviation", p_statistic.getStandardDeviation());
    p_writer.value("skewness", p_statistic.getSkewness());
    p_writer.value("sum", p_statistic.getSum());
    p_writer.value("sumsequared", p_statistic.getSumsq());
    p_writer.value("variance", p_statistic.getVariance());
}

From source file:de.tudarmstadt.ukp.dkpro.core.performance.Stopwatch.java

@Override
public void collectionProcessComplete() throws AnalysisEngineProcessException {
    super.collectionProcessComplete();

    if (isDownstreamTimer()) {
        getLogger().info("Results from Timer '" + timerName + "' after processing all documents.");

        DescriptiveStatistics statTimes = new DescriptiveStatistics();
        for (Long timeValue : times) {
            statTimes.addValue((double) timeValue / 1000);
        }/*from w  w w  .  ja va  2 s. c o m*/
        double sum = statTimes.getSum();
        double mean = statTimes.getMean();
        double stddev = statTimes.getStandardDeviation();

        StringBuilder sb = new StringBuilder();
        sb.append("Estimate after processing " + times.size() + " documents.");
        sb.append("\n");

        Formatter formatter = new Formatter(sb, Locale.US);

        formatter.format("Aggregated time: %,.1fs\n", sum);
        formatter.format("Time / Document: %,.3fs (%,.3fs)\n", mean, stddev);

        formatter.close();

        getLogger().info(sb.toString());

        if (outputFile != null) {
            try {
                Properties props = new Properties();
                props.setProperty(KEY_SUM, "" + sum);
                props.setProperty(KEY_MEAN, "" + mean);
                props.setProperty(KEY_STDDEV, "" + stddev);
                OutputStream out = new FileOutputStream(outputFile);
                props.store(out, "timer " + timerName + " result file");
            } catch (FileNotFoundException e) {
                throw new AnalysisEngineProcessException(e);
            } catch (IOException e) {
                throw new AnalysisEngineProcessException(e);
            }
        }
    }
}

From source file:com.linuxbox.enkive.statistics.consolidation.AbstractConsolidator.java

/**
 * Builds a map that cooresponds to the consolidation methods
 * /* www .j  a v a  2s  .c  o  m*/
 * @param method
 *            - the method to use
 * @param exampleData
 *            - an example data object (for type consistancy after
 *            consolidation)
 * @param statsMaker
 *            - the pre-populated DescriptiveStatstistics object to pull
 *            stats from
 * @param statData
 *            - the map to populate with consolidated data
 */
public void methodMapBuilder(String method, DescriptiveStatistics statsMaker, Map<String, Object> statData) {
    if (method.equals(CONSOLIDATION_SUM)) {
        statData.put(method, statsMaker.getSum());
    } else if (method.equals(CONSOLIDATION_MAX)) {
        statData.put(method, statsMaker.getMax());
    } else if (method.equals(CONSOLIDATION_MIN)) {
        statData.put(method, statsMaker.getMin());
    } else if (method.equals(CONSOLIDATION_AVG)) {
        statData.put(method, statsMaker.getMean());
    }
}

From source file:io.hops.experiments.results.compiler.RawBMResultAggregator.java

public static RawBMResults processSlaveResponses(Collection<Object> responses,
        RawBenchmarkCommand.Request request, Configuration args) {
    DescriptiveStatistics successfulOps = new DescriptiveStatistics();
    DescriptiveStatistics failedOps = new DescriptiveStatistics();
    DescriptiveStatistics speed = new DescriptiveStatistics();
    DescriptiveStatistics duration = new DescriptiveStatistics();
    DescriptiveStatistics noOfAliveNNs = new DescriptiveStatistics();
    for (Object obj : responses) {
        if (!(obj instanceof RawBenchmarkCommand.Response) || (obj instanceof RawBenchmarkCommand.Response
                && ((RawBenchmarkCommand.Response) obj).getPhase() != request.getPhase())) {
            throw new IllegalStateException("Wrong response received from the client");
        } else {/*from   www .j  a v a 2 s . c  o  m*/
            RawBenchmarkCommand.Response response = (RawBenchmarkCommand.Response) obj;
            successfulOps.addValue(response.getTotalSuccessfulOps());
            failedOps.addValue(response.getTotalFailedOps());
            speed.addValue(response.getOpsPerSec());
            duration.addValue(response.getRunTime());
            noOfAliveNNs.addValue(response.getNnCount());
        }
    }

    RawBMResults result = new RawBMResults(args.getNamenodeCount(), (int) Math.floor(noOfAliveNNs.getMean()),
            args.getNdbNodesCount(), request.getPhase(),
            (successfulOps.getSum() / ((duration.getMean() / 1000))), (duration.getMean() / 1000),
            (successfulOps.getSum()), (failedOps.getSum()));
    return result;
}

From source file:com.intuit.tank.persistence.databases.BucketDataItemTest.java

/**
 * Run the DescriptiveStatistics getStats() method test.
 * //w  w w  .  j a  v  a  2s . c  om
 * @throws Exception
 * 
 * @generatedBy CodePro at 9/10/14 10:32 AM
 */
@Test
public void testGetStats_1() throws Exception {
    BucketDataItem fixture = new BucketDataItem(1, new Date(), new DescriptiveStatistics());

    DescriptiveStatistics result = fixture.getStats();

    assertNotNull(result);
    assertEquals(
            "DescriptiveStatistics:\nn: 0\nmin: NaN\nmax: NaN\nmean: NaN\nstd dev: NaN\nmedian: NaN\nskewness: NaN\nkurtosis: NaN\n",
            result.toString());
    assertEquals(Double.NaN, result.getMax(), 1.0);
    assertEquals(Double.NaN, result.getVariance(), 1.0);
    assertEquals(Double.NaN, result.getMean(), 1.0);
    assertEquals(-1, result.getWindowSize());
    assertEquals(0.0, result.getSumsq(), 1.0);
    assertEquals(Double.NaN, result.getKurtosis(), 1.0);
    assertEquals(0.0, result.getSum(), 1.0);
    assertEquals(Double.NaN, result.getSkewness(), 1.0);
    assertEquals(Double.NaN, result.getPopulationVariance(), 1.0);
    assertEquals(Double.NaN, result.getStandardDeviation(), 1.0);
    assertEquals(Double.NaN, result.getGeometricMean(), 1.0);
    assertEquals(0L, result.getN());
    assertEquals(Double.NaN, result.getMin(), 1.0);
}

From source file:com.github.jessemull.microflex.stat.statinteger.SumIntegerTest.java

/**
 * Tests the plate statistics method./*from  w  w  w. jav  a2 s.co m*/
 */
@Test
public void testPlate() {

    for (PlateInteger plate : array) {

        Map<WellInteger, Double> resultMap = new TreeMap<WellInteger, Double>();
        Map<WellInteger, Double> returnedMap = sum.plate(plate);

        for (WellInteger well : plate) {

            double[] input = new double[well.size()];
            int index = 0;

            for (double bd : well) {
                input[index++] = bd;
                ;
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(input);
            double result = stat.getSum();

            resultMap.put(well, result);
        }

        for (WellInteger well : plate) {

            double result = Precision.round(resultMap.get(well), precision);
            double returned = Precision.round(returnedMap.get(well), precision);

            assertTrue(result == returned);
        }
    }
}

From source file:com.github.jessemull.microflexdouble.stat.SumTest.java

/**
 * Tests the plate statistics method.//from   ww w. ja  v  a 2s .co m
 */
@Test
public void testPlate() {

    for (Plate plate : array) {

        Map<Well, Double> resultMap = new TreeMap<Well, Double>();
        Map<Well, Double> returnedMap = sum.plate(plate);

        for (Well well : plate) {

            double[] input = new double[well.size()];
            int index = 0;

            for (double bd : well) {
                input[index++] = bd;
                ;
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(input);
            double result = stat.getSum();

            resultMap.put(well, result);
        }

        for (Well well : plate) {

            double result = Precision.round(resultMap.get(well), precision);
            double returned = Precision.round(returnedMap.get(well), precision);

            assertTrue(result == returned);
        }
    }
}

From source file:com.github.jessemull.microflex.stat.statdouble.SumDoubleTest.java

/**
 * Tests the plate statistics method.//  w w  w .  j  av  a  2s.c  o  m
 */
@Test
public void testPlate() {

    for (PlateDouble plate : array) {

        Map<WellDouble, Double> resultMap = new TreeMap<WellDouble, Double>();
        Map<WellDouble, Double> returnedMap = sum.plate(plate);

        for (WellDouble well : plate) {

            double[] input = new double[well.size()];
            int index = 0;

            for (double bd : well) {
                input[index++] = bd;
                ;
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(input);
            double result = stat.getSum();

            resultMap.put(well, result);
        }

        for (WellDouble well : plate) {

            double result = Precision.round(resultMap.get(well), precision);
            double returned = Precision.round(returnedMap.get(well), precision);

            assertTrue(result == returned);
        }
    }
}

From source file:com.github.jessemull.microflex.stat.statinteger.SumIntegerTest.java

/**
 * Tests set calculation./*from   w  w w.  j a va2s.com*/
 */
@Test
public void testSet() {

    for (PlateInteger plate : array) {

        Map<WellInteger, Double> resultMap = new TreeMap<WellInteger, Double>();
        Map<WellInteger, Double> returnedMap = sum.set(plate.dataSet());

        for (WellInteger well : plate) {

            double[] input = new double[well.size()];
            int index = 0;

            for (double bd : well) {
                input[index++] = bd;
                ;
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(input);
            double result = stat.getSum();

            resultMap.put(well, result);
        }

        for (WellInteger well : plate) {

            double result = Precision.round(resultMap.get(well), precision);
            double returned = Precision.round(returnedMap.get(well), precision);

            assertTrue(result == returned);
        }
    }

}