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.microflex.stat.statbiginteger.MinBigIntegerTest.java

/**
 * Tests the plate statistics method.//from  w ww  . j  a v a2  s  .co  m
 */
@Test
public void testPlate() {

    for (PlateBigInteger plate : array) {

        Map<WellBigInteger, BigDecimal> resultMap = new TreeMap<WellBigInteger, BigDecimal>();
        Map<WellBigInteger, BigDecimal> returnedMap = min.plate(plate);

        for (WellBigInteger well : plate) {

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

            for (BigInteger bi : well) {
                input[index++] = bi.doubleValue();
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(input);
            double resultDouble = stat.getMin();

            BigDecimal result = new BigDecimal(resultDouble);

            resultMap.put(well, result);
        }

        for (WellBigInteger 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.statbiginteger.SumBigIntegerTest.java

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

    for (PlateBigInteger plate : array) {

        Map<WellBigInteger, BigDecimal> resultMap = new TreeMap<WellBigInteger, BigDecimal>();
        Map<WellBigInteger, BigDecimal> returnedMap = sum.plate(plate, mc);

        for (WellBigInteger well : plate) {

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

            for (BigInteger bi : well) {
                input[index++] = bi.doubleValue();
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(input);
            double resultDouble = stat.getSum();

            BigDecimal result = new BigDecimal(resultDouble);

            resultMap.put(well, result);
        }

        for (WellBigInteger 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:es.csic.iiia.planes.util.InverseWishartDistributionTest.java

private double computeRadius(InverseWishartDistribution instance) {
    double[] means = new double[] { 0, 0 };
    MultivariateNormalDistribution uniform = null;

    while (uniform == null) {
        try {//  www  .  ja v a2s. c om
            double[][] covariances = instance.sample().getData();
            uniform = new MultivariateNormalDistribution(means, covariances);
        } catch (MathUnsupportedOperationException ex) {
        }
    }

    DescriptiveStatistics stats = new DescriptiveStatistics(NORMAL_SAMPLES);
    for (int i = 0; i < NORMAL_SAMPLES; i++) {
        double[] xy = uniform.sample();
        final double x = xy[0];
        final double y = xy[1];
        stats.addValue(Math.sqrt(x * x + y * y));
    }

    return stats.getPercentile(90);
}

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

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

    for (Plate plate : array) {

        Map<Well, BigDecimal> resultMap = new TreeMap<Well, BigDecimal>();
        Map<Well, BigDecimal> returnedMap = sum.plate(plate, weights, mc);

        for (Well well : plate) {

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

            for (BigInteger bi : well) {
                input[index] = bi.doubleValue() * weights[index];
                index++;
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(input);
            double resultDouble = stat.getSumsq();

            BigDecimal result = new BigDecimal(resultDouble, mc);

            resultMap.put(well, result);
        }

        for (Well 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.StandardDeviationBigDecimalTest.java

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

    for (PlateBigDecimal plate : array) {

        Map<WellBigDecimal, BigDecimal> resultMap = new TreeMap<WellBigDecimal, BigDecimal>();
        Map<WellBigDecimal, BigDecimal> returnedMap = deviation.plate(plate, mc);

        for (WellBigDecimal well : plate) {

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

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

            DescriptiveStatistics stat = new DescriptiveStatistics(input);
            double resultDouble = stat.getStandardDeviation();

            BigDecimal result = new BigDecimal(resultDouble);

            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.microflexbiginteger.stat.SampleVarianceWeightsTest.java

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

    for (Plate plate : array) {

        Map<Well, BigDecimal> resultMap = new TreeMap<Well, BigDecimal>();
        Map<Well, BigDecimal> returnedMap = variance.plate(plate, weights, mc);

        for (Well well : plate) {

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

            for (BigInteger bi : well) {
                input[index] = bi.doubleValue() * weights[index];
                index++;
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(input);
            double resultDouble = stat.getVariance();

            BigDecimal result = new BigDecimal(resultDouble, mc);

            resultMap.put(well, result);
        }

        for (Well 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.microflexbigdecimal.stat.NTest.java

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

    for (Plate plate : array) {

        List<Double> resultList = new ArrayList<Double>();
        int aggregatedReturned = n.platesAggregated(plate);

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

        assertEquals((int) resultAggregated, aggregatedReturned);
    }
}

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

/**
 * Tests the plate statistics method.// ww  w.java2s . c  om
 */
@Test
public void testPlate() {

    for (PlateBigDecimal plate : array) {

        Map<WellBigDecimal, BigDecimal> resultMap = new TreeMap<WellBigDecimal, BigDecimal>();
        Map<WellBigDecimal, BigDecimal> returnedMap = variance.plate(plate, mc);

        for (WellBigDecimal well : plate) {

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

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

            DescriptiveStatistics stat = new DescriptiveStatistics(input);
            double resultDouble = stat.getVariance();
            resultDouble *= well.size() - 1;
            resultDouble /= well.size();

            BigDecimal result = new BigDecimal(resultDouble);

            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.NDoubleTest.java

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

    for (PlateDouble plate : array) {

        List<Double> resultList = new ArrayList<Double>();
        int aggregatedReturned = n.platesAggregated(plate);

        for (WellDouble well : plate) {

            for (double db : well) {
                resultList.add(db);
            }

        }

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

        assertEquals((int) resultAggregated, aggregatedReturned);
    }
}

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

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

    for (Plate plate : array) {

        List<Double> resultList = new ArrayList<Double>();
        int aggregatedReturned = n.platesAggregated(plate);

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

        assertEquals((int) resultAggregated, aggregatedReturned);
    }
}