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

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

Introduction

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

Prototype

public DescriptiveStatistics(DescriptiveStatistics original) throws NullArgumentException 

Source Link

Document

Copy constructor.

Usage

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

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

    for (Plate plate : array) {

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        BigDecimal aggregatedReturned = max.platesAggregated(plate);

        for (Well well : plate) {
            resultList.addAll(well.data());
        }

        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.getMax();

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble);

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

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

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

    for (Plate plate : array) {

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        BigDecimal aggregatedReturned = min.platesAggregated(plate);

        for (Well well : plate) {
            resultList.addAll(well.data());
        }

        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.getMin();

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble);

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

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

/**
 * Tests the aggregated plate statistics method.
 *///from   w w w.  ja v  a2  s  . c o m
@Test
public void testAggregatedPlate() {

    for (Plate plate : array) {

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        double aggregatedReturned = Precision.round(mean.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.getMean(), precision);

        assertTrue(resultAggregated == aggregatedReturned);
    }
}

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

/**
 * Tests the aggregated plate statistics method.
 *///from  www. j a  v a  2s  .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.getSumsq(), precision);

        assertTrue(resultAggregated == aggregatedReturned);
    }
}

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

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

    Map<Plate, Integer> aggregatedReturnedMap = n.platesAggregated(array);
    Map<Plate, Integer> aggregatedResultMap = new TreeMap<Plate, Integer>();

    for (Plate plate : array) {

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

        for (Well well : plate) {

            for (BigDecimal bd : well) {
                resultList.add(bd.doubleValue());
            }

        }

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

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

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double resultAggregated = statAggregated.getN();

        aggregatedResultMap.put(plate, (int) resultAggregated);
    }

    for (Plate plate : array) {

        int result = aggregatedResultMap.get(plate);
        int returned = aggregatedReturnedMap.get(plate);

        assertEquals(result, returned);
    }

}

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

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

    for (Plate plate : array) {

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

        for (Well well : plate) {
            resultList.addAll(well.data());
        }

        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);

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

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

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

    Map<Plate, Integer> aggregatedReturnedMap = n.platesAggregated(array);
    Map<Plate, Integer> aggregatedResultMap = new TreeMap<Plate, Integer>();

    for (Plate plate : array) {

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

        for (Well well : plate) {

            for (BigInteger bi : well) {
                resultList.add(bi.doubleValue());
            }

        }

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

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

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double resultAggregated = statAggregated.getN();

        aggregatedResultMap.put(plate, (int) resultAggregated);
    }

    for (Plate plate : array) {

        int result = aggregatedResultMap.get(plate);
        int returned = aggregatedReturnedMap.get(plate);

        assertEquals(result, returned);
    }

}

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

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

    for (Plate plate : array) {

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

        for (Well well : plate) {
            resultList.addAll(well.data());
        }

        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.getMean();

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble);

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

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

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

    for (Plate plate : array) {

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        double aggregatedReturned = Precision.round(mean.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.getGeometricMean(), precision);

        assertTrue(resultAggregated == aggregatedReturned);
    }
}

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

/**
 * Tests the aggregated plate statistics method.
 *///from w w w . ja va  2 s .  c o  m
@Test
public void testAggregatedPlate() {

    for (Plate plate : array) {

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        double aggregatedReturned = Precision.round(variance.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.getVariance(), precision);

        assertTrue(resultAggregated == aggregatedReturned);
    }
}