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.microflexinteger.stat.StandardDeviationTest.java

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

    for (Plate plate : array) {

        List<Double> resultList = new ArrayList<Double>();
        double aggregatedReturned = Precision.round(deviation.platesAggregated(plate), precision);

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

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

        assertTrue(resultAggregated == aggregatedReturned);
    }
}

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

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

    for (Plate plate : array) {

        List<Double> resultList = new ArrayList<Double>();
        double aggregatedReturned = Precision.round(deviation.platesAggregated(plate), precision);

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

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double resultAggregated = Precision.round(statAggregated.getStandardDeviation(), precision);

        assertTrue(resultAggregated == aggregatedReturned);
    }
}

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

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

    for (PlateBigDecimal plate : arrayIndices) {

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

        Map<WellBigDecimal, BigDecimal> resultMap = new TreeMap<WellBigDecimal, BigDecimal>();
        Map<WellBigDecimal, BigDecimal> returnedMap = variance.plate(plate,
                ArrayUtils.subarray(weightsIndices, begin, end), begin, end - begin, mc);

        for (WellBigDecimal well : plate) {

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

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

            DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end));
            double resultDouble = stat.getVariance();

            BigDecimal result = new BigDecimal(resultDouble, mc);

            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.statdouble.MaxDoubleTest.java

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

    for (PlateDouble plate : array) {

        List<Double> resultList = new ArrayList<Double>();
        double aggregatedReturned = Precision.round(max.platesAggregated(plate), precision);

        for (WellDouble 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);
        }

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double resultAggregated = Precision.round(statAggregated.getMax(), precision);

        assertTrue(resultAggregated == aggregatedReturned);
    }
}

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

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

    for (PlateDouble plate : array) {

        List<Double> resultList = new ArrayList<Double>();
        double aggregatedReturned = Precision.round(min.platesAggregated(plate), precision);

        for (WellDouble 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);
        }

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double resultAggregated = Precision.round(statAggregated.getMin(), precision);

        assertTrue(resultAggregated == aggregatedReturned);
    }
}

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

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

    for (PlateDouble plate : array) {

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

        for (WellDouble 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);
        }

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double resultAggregated = Precision.round(statAggregated.getSum(), precision);

        assertTrue(resultAggregated == aggregatedReturned);
    }
}

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

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

    for (PlateDouble plate : array) {

        List<Double> resultList = new ArrayList<Double>();
        double aggregatedReturned = Precision.round(mean.platesAggregated(plate), precision);

        for (WellDouble 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);
        }

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double resultAggregated = Precision.round(statAggregated.getMean(), precision);

        assertTrue(resultAggregated == aggregatedReturned);
    }
}

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

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

    for (PlateInteger plate : array) {

        List<Double> resultList = new ArrayList<Double>();
        double aggregatedReturned = Precision.round(max.platesAggregated(plate), precision);

        for (WellInteger well : plate) {
            resultList.addAll(well.toDouble());
        }

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

        assertTrue(resultAggregated == aggregatedReturned);
    }
}

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

/**
 * Tests the aggregated plate statistics method.
 *///from www . j ava2 s.com
@Test
public void testAggregatedPlate() {

    for (PlateInteger plate : array) {

        List<Double> resultList = new ArrayList<Double>();
        double aggregatedReturned = Precision.round(min.platesAggregated(plate), precision);

        for (WellInteger well : plate) {
            resultList.addAll(well.toDouble());
        }

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

        assertTrue(resultAggregated == aggregatedReturned);
    }
}

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

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

    for (PlateInteger plate : array) {

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

        for (WellInteger well : plate) {
            resultList.addAll(well.toDouble());
        }

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

        assertTrue(resultAggregated == aggregatedReturned);
    }
}