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

/**
 * Tests the plate statistics method using the values between the indices.
 *///  ww  w  . j  a  v  a2  s  . c o m
@Test
public void testPlateIndices() {

    for (Plate plate : arrayIndices) {

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

        Map<Well, Double> resultMap = new TreeMap<Well, Double>();
        Map<Well, Double> returnedMap = sum.plate(plate, ArrayUtils.subarray(weightsIndices, begin, end), begin,
                end - begin);

        for (Well well : plate) {

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

            for (double db : well) {
                input[index] = db * weightsIndices[index];
                index++;
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end));
            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.microflexdouble.stat.SumWeightsTest.java

/**
 * Tests set calculation using indices./*from w ww.  j  a  v  a  2 s  . co m*/
 */
@Test
public void testSetIndices() {

    for (Plate plate : arrayIndices) {

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

        Map<Well, Double> resultMap = new TreeMap<Well, Double>();
        Map<Well, Double> returnedMap = sum.set(plate.dataSet(),
                ArrayUtils.subarray(weightsIndices, begin, end), begin, end - begin);

        for (Well well : plate) {

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

            for (double db : well) {
                input[index] = db * weightsIndices[index];
                index++;
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end));
            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.SumDoubleWeightsTest.java

/**
 * Tests the plate statistics method using the values between the indices.
 *//*w  ww  .  ja  v a 2  s.c o  m*/
@Test
public void testPlateIndices() {

    for (PlateDouble plate : arrayIndices) {

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

        Map<WellDouble, Double> resultMap = new TreeMap<WellDouble, Double>();
        Map<WellDouble, Double> returnedMap = sum.plate(plate, ArrayUtils.subarray(weightsIndices, begin, end),
                begin, end - begin);

        for (WellDouble well : plate) {

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

            for (double db : well) {
                input[index] = db * weightsIndices[index];
                index++;
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end));
            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.statdouble.SumDoubleWeightsTest.java

/**
 * Tests set calculation using indices./*w  ww .j  a  v  a2 s  . c  o  m*/
 */
@Test
public void testSetIndices() {

    for (PlateDouble plate : arrayIndices) {

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

        Map<WellDouble, Double> resultMap = new TreeMap<WellDouble, Double>();
        Map<WellDouble, Double> returnedMap = sum.set(plate.dataSet(),
                ArrayUtils.subarray(weightsIndices, begin, end), begin, end - begin);

        for (WellDouble well : plate) {

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

            for (double db : well) {
                input[index] = db * weightsIndices[index];
                index++;
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end));
            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.SumIntegerWeightsTest.java

/**
 * Tests the plate statistics method using the values between the indices.
 *///from   w ww  .  j  ava  2  s .c o  m
@Test
public void testPlateIndices() {

    for (PlateInteger plate : arrayIndices) {

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

        Map<WellInteger, Double> resultMap = new TreeMap<WellInteger, Double>();
        Map<WellInteger, Double> returnedMap = sum.plate(plate, ArrayUtils.subarray(weightsIndices, begin, end),
                begin, end - begin);

        for (WellInteger well : plate) {

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

            for (double db : well) {
                input[index] = db * weightsIndices[index];
                index++;
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end));
            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.microflex.stat.statinteger.SumIntegerWeightsTest.java

/**
 * Tests set calculation using indices.//from www .  j a v a 2s.  c o m
 */
@Test
public void testSetIndices() {

    for (PlateInteger plate : arrayIndices) {

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

        Map<WellInteger, Double> resultMap = new TreeMap<WellInteger, Double>();
        Map<WellInteger, Double> returnedMap = sum.set(plate.dataSet(),
                ArrayUtils.subarray(weightsIndices, begin, end), begin, end - begin);

        for (WellInteger well : plate) {

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

            for (double db : well) {
                input[index] = db * weightsIndices[index];
                index++;
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end));
            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.SumWeightsTest.java

/**
 * Tests the aggregated plate statistics method using the values between the indices of
 * the array.//w  ww.  j  a v  a  2 s  .c  om
 */
@Test
public void testAggregatedPlateArrayIndices() {

    int begin = random.nextInt(arrayIndices[0].first().size() - 4);
    int end = begin + random.nextInt(3) + 3;

    Map<Plate, Double> aggregatedReturnedMap = sum.platesAggregated(arrayIndices, weightsIndices, begin,
            end - begin);
    Map<Plate, Double> aggregatedResultMap = new TreeMap<Plate, Double>();

    for (Plate plate : arrayIndices) {

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

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

        aggregatedResultMap.put(plate, aggregatedResult);

    }

    for (Plate plate : arrayIndices) {

        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 the values between the indices of
 * the array.//from  w w  w. j  a  v a 2 s  .  com
 */
@Test
public void testAggregatedPlateArrayIndices() {

    int begin = random.nextInt(arrayIndices[0].first().size() - 4);
    int end = begin + random.nextInt(3) + 3;

    Map<PlateDouble, Double> aggregatedReturnedMap = sum.platesAggregated(arrayIndices, weightsIndices, begin,
            end - begin);
    Map<PlateDouble, Double> aggregatedResultMap = new TreeMap<PlateDouble, Double>();

    for (PlateDouble plate : arrayIndices) {

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

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

        aggregatedResultMap.put(plate, aggregatedResult);

    }

    for (PlateDouble plate : arrayIndices) {

        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 the values between the indices of
 * the array.//www . j a va2  s .  co m
 */
@Test
public void testAggregatedPlateArrayIndices() {

    int begin = random.nextInt(arrayIndices[0].first().size() - 4);
    int end = begin + random.nextInt(3) + 3;

    Map<PlateInteger, Double> aggregatedReturnedMap = sum.platesAggregated(arrayIndices, weightsIndices, begin,
            end - begin);
    Map<PlateInteger, Double> aggregatedResultMap = new TreeMap<PlateInteger, Double>();

    for (PlateInteger plate : arrayIndices) {

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

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

        aggregatedResultMap.put(plate, aggregatedResult);

    }

    for (PlateInteger plate : arrayIndices) {

        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.
 *//*from  ww w . j a v a2s.c o  m*/
@Test
public void testAggregatedPlate() {

    for (Plate plate : array) {

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        double aggregatedReturned = Precision.round(sum.platesAggregated(plate, weights), precision);

        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 resultAggregated = Precision.round(statAggregated.getSum(), precision);

        assertTrue(resultAggregated == aggregatedReturned);
    }
}