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.microflexbigdecimal.stat.SumWeightsTest.java

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

    for (Plate plate : array) {

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

        for (Well well : plate) {

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

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

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

            BigDecimal result = new BigDecimal(resultDouble, mc);

            resultMap.put(well, result);
        }

        for (Well 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.SumBigIntegerWeightsTest.java

/**
 * Tests the aggregated plate statistics method.
 *///from w w w  .  j  ava 2 s .c  om
@Test
public void testAggregatedPlate() {

    for (PlateBigInteger plate : array) {

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        BigDecimal aggregatedReturned = sum.platesAggregated(plate, weights, mc);

        for (WellBigInteger 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 resultAggregatedDouble = statAggregated.getSum();

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc);

        BigDecimal[] corrected = correctRoundingErrors(aggregatedResult, aggregatedReturned);
        assertEquals(corrected[0], corrected[1]);
    }
}

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

/**
 * Tests the aggregated plate statistics method.
 *///  w w  w. ja  va 2 s. co  m
@Test
public void testAggregatedSet() {

    for (PlateBigInteger plate : array) {

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        BigDecimal aggregatedReturned = sum.setsAggregated(plate.dataSet(), weights, mc);

        for (WellBigInteger 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 resultAggregatedDouble = statAggregated.getSum();

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc);

        BigDecimal[] corrected = correctRoundingErrors(aggregatedResult, aggregatedReturned);
        assertEquals(corrected[0], corrected[1]);
    }
}

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

/**
 * Tests the aggregated plate statistics method.
 *///from  w  w  w  .  j a  v a2 s.  c  om
@Test
public void testAggregatedPlate() {

    for (Plate plate : array) {

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        BigDecimal aggregatedReturned = sum.platesAggregated(plate, weights, mc);

        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 resultAggregatedDouble = statAggregated.getSum();

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc);

        BigDecimal[] corrected = correctRoundingErrors(aggregatedResult, aggregatedReturned);
        assertEquals(corrected[0], corrected[1]);
    }
}

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

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

    for (Plate plate : array) {

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        BigDecimal aggregatedReturned = sum.setsAggregated(plate.dataSet(), weights, mc);

        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 resultAggregatedDouble = statAggregated.getSum();

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc);

        BigDecimal[] corrected = correctRoundingErrors(aggregatedResult, aggregatedReturned);
        assertEquals(corrected[0], corrected[1]);
    }
}

From source file:com.github.jessemull.microflex.stat.statbigdecimal.SumBigDecimalWeightsTest.java

/**
 * Tests the aggregated plate statistics method.
 *///from w w w  . j  a  va 2  s.  c om
@Test
public void testAggregatedPlate() {

    for (PlateBigDecimal plate : array) {

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        BigDecimal aggregatedReturned = sum.platesAggregated(plate, weights, mc);

        for (WellBigDecimal well : plate) {

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

            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 resultAggregatedDouble = statAggregated.getSum();

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc);

        BigDecimal[] corrected = correctRoundingErrors(aggregatedResult, aggregatedReturned);
        assertEquals(corrected[0], corrected[1]);
    }
}

From source file:com.github.jessemull.microflex.stat.statbigdecimal.SumBigDecimalWeightsTest.java

/**
 * Tests the aggregated plate statistics method.
 *///  w ww . jav a  2  s  .  c  o m
@Test
public void testAggregatedSet() {

    for (PlateBigDecimal plate : array) {

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        BigDecimal aggregatedReturned = sum.setsAggregated(plate.dataSet(), weights, mc);

        for (WellBigDecimal well : plate) {

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

            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 resultAggregatedDouble = statAggregated.getSum();

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc);

        BigDecimal[] corrected = correctRoundingErrors(aggregatedResult, aggregatedReturned);
        assertEquals(corrected[0], corrected[1]);
    }
}

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

/**
 * Tests the aggregated plate statistics method.
 *//*from   w  w  w  . j  a  va2  s .c o m*/
@Test
public void testAggregatedPlate() {

    for (Plate plate : array) {

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        BigDecimal aggregatedReturned = sum.platesAggregated(plate, weights, mc);

        for (Well well : plate) {

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

            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 resultAggregatedDouble = statAggregated.getSum();

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc);

        BigDecimal[] corrected = correctRoundingErrors(aggregatedResult, aggregatedReturned);
        assertEquals(corrected[0], corrected[1]);
    }
}

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

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

    for (Plate plate : array) {

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        BigDecimal aggregatedReturned = sum.setsAggregated(plate.dataSet(), weights, mc);

        for (Well well : plate) {

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

            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 resultAggregatedDouble = statAggregated.getSum();

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc);

        BigDecimal[] corrected = correctRoundingErrors(aggregatedResult, aggregatedReturned);
        assertEquals(corrected[0], corrected[1]);
    }
}

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

/**
 * Tests the aggregated plate statistics method using the values between the indices.
 *//* w  w  w . ja  v  a 2s .co m*/
@Test
public void testAggregatedPlateIndices() {

    for (PlateBigInteger plate : arrayIndices) {

        int begin = random.nextInt(plate.first().size() - 4);
        int end = begin + random.nextInt(3) + 3;

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        BigDecimal aggregatedReturned = sum.platesAggregated(plate, weightsIndices, begin, end - begin, mc);

        for (WellBigInteger well : plate) {

            List<BigDecimal> input = well.toBigDecimal().subList(begin, end);

            for (int i = 0; i < input.size(); i++) {
                resultList.add(input.get(i).multiply(new BigDecimal(weightsIndices[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 resultAggregatedDouble = statAggregated.getSum();

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc);

        BigDecimal[] corrected = correctRoundingErrors(aggregatedResult, aggregatedReturned);
        assertEquals(corrected[0], corrected[1]);
    }
}