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.github.jessemull.microflex.stat.statbigdecimal.SumBigDecimalTest.java

/**
 * Tests set calculation.//w ww .j  a v  a 2 s .  c  o m
 */
@Test
public void testSet() {

    for (PlateBigDecimal plate : array) {

        Map<WellBigDecimal, BigDecimal> resultMap = new TreeMap<WellBigDecimal, BigDecimal>();
        Map<WellBigDecimal, BigDecimal> returnedMap = sum.set(plate.dataSet(), mc);

        for (WellBigDecimal well : plate) {

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

            for (BigDecimal bd : well) {
                input[index++] = bd.doubleValue();
            }

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

            BigDecimal result = new BigDecimal(resultDouble);

            resultMap.put(well, result);
        }

        for (WellBigDecimal well : plate) {

            BigDecimal result = resultMap.get(well);
            BigDecimal returned = returnedMap.get(well);

            BigDecimal[] corrected = correctRoundingErrors(result, returned);

            assertEquals(corrected[0], corrected[1]);
        }
    }

}

From source file:com.github.jessemull.microflex.stat.statbiginteger.SumBigIntegerTest.java

/**
 * Tests the plate statistics method./*from  ww  w.ja  v a2s.  c o  m*/
 */
@Test
public void testPlate() {

    for (PlateBigInteger plate : array) {

        Map<WellBigInteger, BigDecimal> resultMap = new TreeMap<WellBigInteger, BigDecimal>();
        Map<WellBigInteger, BigDecimal> returnedMap = sum.plate(plate, mc);

        for (WellBigInteger well : plate) {

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

            for (BigInteger bi : well) {
                input[index++] = bi.doubleValue();
            }

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

            BigDecimal result = new BigDecimal(resultDouble);

            resultMap.put(well, result);
        }

        for (WellBigInteger well : plate) {

            BigDecimal result = resultMap.get(well);
            BigDecimal returned = returnedMap.get(well);

            BigDecimal[] corrected = correctRoundingErrors(result, returned);

            assertEquals(corrected[0], corrected[1]);
        }
    }
}

From source file:com.github.jessemull.microflex.stat.statbiginteger.SumBigIntegerTest.java

/**
 * Tests set calculation.//  www  . j ava2 s .c o  m
 */
@Test
public void testSet() {

    for (PlateBigInteger plate : array) {

        Map<WellBigInteger, BigDecimal> resultMap = new TreeMap<WellBigInteger, BigDecimal>();
        Map<WellBigInteger, BigDecimal> returnedMap = sum.set(plate.dataSet(), mc);

        for (WellBigInteger well : plate) {

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

            for (BigInteger bi : well) {
                input[index++] = bi.doubleValue();
            }

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

            BigDecimal result = new BigDecimal(resultDouble);

            resultMap.put(well, result);
        }

        for (WellBigInteger well : plate) {

            BigDecimal result = resultMap.get(well);
            BigDecimal returned = returnedMap.get(well);

            BigDecimal[] corrected = correctRoundingErrors(result, returned);

            assertEquals(corrected[0], corrected[1]);
        }
    }

}

From source file:com.loadtesting.core.data.TimeSerieData.java

public TimeSerieData(String name, List<TimeSample> samples, CapturerConfig config) {
    this.name = name;
    this.unit = config.getUnit();
    this.volume = samples.size();
    if (volume > 0) {
        TimeSample first = samples.get(0);
        this.unit = first.getTimeUnit();
        this.opening = first.getTime(unit);
        TimeSample last = samples.get(volume - 1);
        this.closing = last.getTime(unit);
        this.samples = config.getFilter().filter(samples);

        DescriptiveStatistics stats = new DescriptiveStatistics(volume);
        for (TimeSample timeSample : samples) {
            stats.addValue(timeSample.getTime(unit));
        }/*w w  w  .  j a  v a2  s  .  c  o  m*/
        this.high = stats.getMax();
        this.low = stats.getMin();
        this.median = (high + low) / 2;
        this.typical = (high + low + closing) / 3;
        this.weightedClose = (high + low + closing + closing) / 4;
        this.sma = stats.getMean();
        this.variance = stats.getVariance();
        this.sd = stats.getStandardDeviation();
        this.sum = stats.getSum();
        this.sumsq = stats.getSumsq();
        this.skewness = stats.getSkewness();
        this.kurtosis = stats.getKurtosis();
        this.geometricMean = stats.getGeometricMean();
        this.populationVariance = stats.getPopulationVariance();
    } else {
        this.samples = samples;
    }
}

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

/**
 * Tests the aggregated plate statistics method using a collection.
 *//*w  w w.  j a  va  2s.  co m*/
@Test
public void testAggregatedPlateCollection() {

    List<Plate> collection = Arrays.asList(array);
    Map<Plate, Double> aggregatedReturnedMap = sum.platesAggregated(collection, weights);
    Map<Plate, Double> aggregatedResultMap = new TreeMap<Plate, Double>();

    for (Plate plate : collection) {

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();

        for (Well well : plate) {

            List<BigDecimal> input = well.toBigDecimal();

            for (int i = 0; i < input.size(); i++) {
                resultList.add(input.get(i).multiply(new BigDecimal(weights[i])));
            }

        }

        double[] inputAggregated = new double[resultList.size()];

        for (int i = 0; i < resultList.size(); i++) {
            inputAggregated[i] = resultList.get(i).doubleValue();
        }

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double aggregatedResult = statAggregated.getSum();

        aggregatedResultMap.put(plate, aggregatedResult);
    }

    for (Plate plate : collection) {

        double result = Precision.round(aggregatedResultMap.get(plate), precision);
        double returned = Precision.round(aggregatedReturnedMap.get(plate), precision);

        assertTrue(result == returned);
    }
}

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

/**
 * Tests the aggregated plate statistics method using an array.
 *//*ww  w.  j a  v a  2  s .c  o m*/
@Test
public void testAggregatedPlateArray() {

    Map<Plate, Double> aggregatedReturnedMap = sum.platesAggregated(array, weights);
    Map<Plate, Double> aggregatedResultMap = new TreeMap<Plate, Double>();

    for (Plate plate : array) {

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();

        for (Well well : plate) {

            List<BigDecimal> input = well.toBigDecimal();

            for (int i = 0; i < input.size(); i++) {
                resultList.add(input.get(i).multiply(new BigDecimal(weights[i])));
            }

        }

        double[] inputAggregated = new double[resultList.size()];

        for (int i = 0; i < resultList.size(); i++) {
            inputAggregated[i] = resultList.get(i).doubleValue();
        }

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double aggregatedResult = statAggregated.getSum();

        aggregatedResultMap.put(plate, aggregatedResult);
    }

    for (Plate plate : array) {

        double result = Precision.round(aggregatedResultMap.get(plate), precision);
        double returned = Precision.round(aggregatedReturnedMap.get(plate), precision);

        assertTrue(result == returned);
    }

}

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

/**
 * Tests the aggregated plate statistics method using a collection.
 *//*from ww w .  j a v  a2  s.c o  m*/
@Test
public void testAggregatedPlateCollection() {

    List<PlateDouble> collection = Arrays.asList(array);
    Map<PlateDouble, Double> aggregatedReturnedMap = sum.platesAggregated(collection, weights);
    Map<PlateDouble, Double> aggregatedResultMap = new TreeMap<PlateDouble, Double>();

    for (PlateDouble plate : collection) {

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();

        for (WellDouble well : plate) {

            List<BigDecimal> input = well.toBigDecimal();

            for (int i = 0; i < input.size(); i++) {
                resultList.add(input.get(i).multiply(new BigDecimal(weights[i])));
            }

        }

        double[] inputAggregated = new double[resultList.size()];

        for (int i = 0; i < resultList.size(); i++) {
            inputAggregated[i] = resultList.get(i).doubleValue();
        }

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double aggregatedResult = statAggregated.getSum();

        aggregatedResultMap.put(plate, aggregatedResult);
    }

    for (PlateDouble plate : collection) {

        double result = Precision.round(aggregatedResultMap.get(plate), precision);
        double returned = Precision.round(aggregatedReturnedMap.get(plate), precision);

        assertTrue(result == returned);
    }
}

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

/**
 * Tests the aggregated plate statistics method using an array.
 */// w  w  w. j av  a  2 s  .c om
@Test
public void testAggregatedPlateArray() {

    Map<PlateDouble, Double> aggregatedReturnedMap = sum.platesAggregated(array, weights);
    Map<PlateDouble, Double> aggregatedResultMap = new TreeMap<PlateDouble, Double>();

    for (PlateDouble plate : array) {

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();

        for (WellDouble well : plate) {

            List<BigDecimal> input = well.toBigDecimal();

            for (int i = 0; i < input.size(); i++) {
                resultList.add(input.get(i).multiply(new BigDecimal(weights[i])));
            }

        }

        double[] inputAggregated = new double[resultList.size()];

        for (int i = 0; i < resultList.size(); i++) {
            inputAggregated[i] = resultList.get(i).doubleValue();
        }

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double aggregatedResult = statAggregated.getSum();

        aggregatedResultMap.put(plate, aggregatedResult);
    }

    for (PlateDouble plate : array) {

        double result = Precision.round(aggregatedResultMap.get(plate), precision);
        double returned = Precision.round(aggregatedReturnedMap.get(plate), precision);

        assertTrue(result == returned);
    }

}

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

/**
 * Tests the aggregated plate statistics method using a collection.
 *//*from  ww w. ja v  a 2  s  . c om*/
@Test
public void testAggregatedPlateCollection() {

    List<PlateInteger> collection = Arrays.asList(array);
    Map<PlateInteger, Double> aggregatedReturnedMap = sum.platesAggregated(collection, weights);
    Map<PlateInteger, Double> aggregatedResultMap = new TreeMap<PlateInteger, Double>();

    for (PlateInteger plate : collection) {

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();

        for (WellInteger well : plate) {

            List<BigDecimal> input = well.toBigDecimal();

            for (int i = 0; i < input.size(); i++) {
                resultList.add(input.get(i).multiply(new BigDecimal(weights[i])));
            }

        }

        double[] inputAggregated = new double[resultList.size()];

        for (int i = 0; i < resultList.size(); i++) {
            inputAggregated[i] = resultList.get(i).doubleValue();
        }

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double aggregatedResult = statAggregated.getSum();

        aggregatedResultMap.put(plate, aggregatedResult);
    }

    for (PlateInteger plate : collection) {

        double result = Precision.round(aggregatedResultMap.get(plate), precision);
        double returned = Precision.round(aggregatedReturnedMap.get(plate), precision);

        assertTrue(result == returned);
    }
}

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

/**
 * Tests the aggregated plate statistics method using an array.
 *///from w w w.jav  a2 s  . co m
@Test
public void testAggregatedPlateArray() {

    Map<PlateInteger, Double> aggregatedReturnedMap = sum.platesAggregated(array, weights);
    Map<PlateInteger, Double> aggregatedResultMap = new TreeMap<PlateInteger, Double>();

    for (PlateInteger plate : array) {

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();

        for (WellInteger well : plate) {

            List<BigDecimal> input = well.toBigDecimal();

            for (int i = 0; i < input.size(); i++) {
                resultList.add(input.get(i).multiply(new BigDecimal(weights[i])));
            }

        }

        double[] inputAggregated = new double[resultList.size()];

        for (int i = 0; i < resultList.size(); i++) {
            inputAggregated[i] = resultList.get(i).doubleValue();
        }

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double aggregatedResult = statAggregated.getSum();

        aggregatedResultMap.put(plate, aggregatedResult);
    }

    for (PlateInteger plate : array) {

        double result = Precision.round(aggregatedResultMap.get(plate), precision);
        double returned = Precision.round(aggregatedReturnedMap.get(plate), precision);

        assertTrue(result == returned);
    }

}