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 aggregated plate statistics method using the values between the indices of
 * the collection.// w ww  .j  a  va2 s.c  om
 */
@Test
public void testAggregatedPlateCollectionIndices() {

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

    List<Plate> collection = Arrays.asList(arrayIndices);
    Map<Plate, Double> aggregatedReturnedMap = sum.platesAggregated(collection, weightsIndices, begin,
            end - begin);

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

    for (Plate plate : array) {

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        double aggregatedReturned = Precision.round(sum.setsAggregated(plate.dataSet(), 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 aggregatedResult = Precision.round(statAggregated.getSum(), precision);

        assertTrue(aggregatedResult == aggregatedReturned);
    }
}

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

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

    List<WellSet> collection = new ArrayList<WellSet>();

    for (Plate plate : array) {
        collection.add(plate.dataSet());
    }

    Map<WellSet, Double> aggregatedReturnedMap = sum.setsAggregated(collection, weights);
    Map<WellSet, Double> aggregatedResultMap = new TreeMap<WellSet, Double>();

    for (WellSet set : collection) {

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

        for (Well well : set) {

            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(set, aggregatedResult);
    }

    for (WellSet set : collection) {

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

        assertTrue(result == returned);
    }
}

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

/**
 * Tests the aggregated plate statistics method.
 *///  w ww .jav a2s .  c  o  m
@Test
public void testAggregatedPlate() {

    for (PlateDouble plate : array) {

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

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

        assertTrue(resultAggregated == aggregatedReturned);
    }
}

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 collection.//from ww w  .ja  v a  2 s  .  com
 */
@Test
public void testAggregatedPlateCollectionIndices() {

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

    List<PlateDouble> collection = Arrays.asList(arrayIndices);
    Map<PlateDouble, Double> aggregatedReturnedMap = sum.platesAggregated(collection, weightsIndices, begin,
            end - begin);

    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().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 : 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.
 *//*from ww  w .  j  a v a2s.  com*/
@Test
public void testAggregatedSet() {

    for (PlateDouble plate : array) {

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

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

        assertTrue(aggregatedResult == aggregatedReturned);
    }
}

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

/**
 * Tests the aggregated plate statistics method using a collection.
 *///www. j  av  a 2s. c  o  m
@Test
public void testAggregatedSetCollection() {

    List<WellSetDouble> collection = new ArrayList<WellSetDouble>();

    for (PlateDouble plate : array) {
        collection.add(plate.dataSet());
    }

    Map<WellSetDouble, Double> aggregatedReturnedMap = sum.setsAggregated(collection, weights);
    Map<WellSetDouble, Double> aggregatedResultMap = new TreeMap<WellSetDouble, Double>();

    for (WellSetDouble set : collection) {

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

        for (WellDouble well : set) {

            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(set, aggregatedResult);
    }

    for (WellSetDouble set : collection) {

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

        assertTrue(result == returned);
    }
}

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

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

    for (PlateInteger plate : array) {

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

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

        assertTrue(resultAggregated == aggregatedReturned);
    }
}

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 collection.//from w w w .ja  va  2 s . com
 */
@Test
public void testAggregatedPlateCollectionIndices() {

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

    List<PlateInteger> collection = Arrays.asList(arrayIndices);
    Map<PlateInteger, Double> aggregatedReturnedMap = sum.platesAggregated(collection, weightsIndices, begin,
            end - begin);

    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().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 : 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.
 */// w  w  w.ja v  a2s.  co  m
@Test
public void testAggregatedSet() {

    for (PlateInteger plate : array) {

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

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

        assertTrue(aggregatedResult == aggregatedReturned);
    }
}