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

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

    for (Plate plate : array) {

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

        assertTrue(resultAggregated == aggregatedReturned);
    }
}

From source file:com.github.jessemull.microflexinteger.stat.GeometricMeanTest.java

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

    for (Plate plate : array) {

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

        assertTrue(resultAggregated == aggregatedReturned);
    }
}

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

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

    for (Plate plate : array) {

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

        assertTrue(resultAggregated == aggregatedReturned);
    }
}

From source file:com.github.jessemull.microflexinteger.stat.SampleVarianceTest.java

/**
 * Tests the aggregated plate statistics method.
 *//*from  www. j  av  a2s  .  c  om*/
@Test
public void testAggregatedPlate() {

    for (Plate plate : array) {

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

        assertTrue(resultAggregated == aggregatedReturned);
    }
}

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

/**
 * Tests the plate statistics method using the values between the indices.
 *///from ww  w. j a va  2 s  . 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 = sum.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.getSum();

            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.statbigdecimal.MeanBigDecimalWeightsTest.java

/**
 * Tests the plate statistics method using the values between the indices.
 *///from   w ww.  j a v  a2 s .com
@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 = mean.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.getMean();

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

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

    for (Plate plate : array) {

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

        assertTrue(resultAggregated == aggregatedReturned);
    }
}

From source file:com.github.jessemull.microflexinteger.stat.PopulationVarianceTest.java

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

    for (Plate plate : array) {

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

        assertTrue(resultAggregated == aggregatedReturned);
    }
}

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

/**
 * Tests the plate statistics method using the values between the indices.
 *//*from   w  w w .  ja  va2  s.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 = sum.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.getSumsq();

            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.vsthost.rnd.commons.math.ext.linear.EMatrixUtils.java

/**
 * Returns the standard deviations of rows.
 *
 * @param matrix The matrix of which the standard deviations of rows to be computed
 * @return A double array of row standard deviations.
 *//* w w w.j a v a2  s  .  c  om*/
public static double[] rowStdDevs(RealMatrix matrix) {
    double[] retval = new double[matrix.getRowDimension()];
    for (int i = 0; i < retval.length; i++) {
        retval[i] = new DescriptiveStatistics(matrix.getRow(i)).getStandardDeviation();
    }
    return retval;
}