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

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

Introduction

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

Prototype

public double getPercentile(double p) throws MathIllegalStateException, MathIllegalArgumentException 

Source Link

Document

Returns an estimate for the pth percentile of the stored values.

Usage

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

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

    for (Plate plate : array) {

        int inputPercentile = 1 + random.nextInt(100);

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

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

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

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble);

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

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

/**
 * Tests the aggregated plate statistics method.
 *///  www  .j ava2s . c om
@Test
public void testAggregatedSet() {

    for (Plate plate : array) {

        int inputPercentile = 1 + random.nextInt(100);

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        BigDecimal aggregatedReturned = percentile.setsAggregated(plate.dataSet(), inputPercentile);

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

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

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble);

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

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

/**
 * Tests the aggregated plate statistics method using the values between the indices.
 *//*ww w . ja  va2s  .  c o  m*/
@Test
public void testAggregatedPlateIndices() {

    for (Plate plate : arrayIndices) {

        int inputPercentile = 1 + random.nextInt(100);

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

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        BigDecimal aggregatedReturned = percentile.platesAggregated(plate, begin, end - begin, inputPercentile);

        for (Well well : plate) {
            resultList.addAll(well.data().subList(begin, end));
        }

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

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble);

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

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

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

    for (PlateBigDecimal plate : array) {

        int inputPercentile = 1 + random.nextInt(100);

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

        for (WellBigDecimal 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.getPercentile(inputPercentile);

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble);

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

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

/**
 * Tests the aggregated plate statistics method.
 *///from ww  w  .  java 2  s  .c  o m
@Test
public void testAggregatedSet() {

    for (PlateBigDecimal plate : array) {

        int inputPercentile = 1 + random.nextInt(100);

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        BigDecimal aggregatedReturned = percentile.setsAggregated(plate.dataSet(), inputPercentile);

        for (WellBigDecimal 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.getPercentile(inputPercentile);

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble);

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

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

/**
 * Tests the aggregated plate statistics method using the values between the indices.
 *//*ww  w . j  av a2  s  . com*/
@Test
public void testAggregatedSetIndices() {

    for (Plate plate : arrayIndices) {

        int inputPercentile = 1 + random.nextInt(100);

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

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        BigDecimal aggregatedReturned = percentile.setsAggregated(plate.dataSet(), begin, end - begin,
                inputPercentile);

        for (Well well : plate) {
            resultList.addAll(well.data().subList(begin, end));
        }

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

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble);

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

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

/**
 * Tests the aggregated plate statistics method using the values between the indices.
 *///from  w w w.  j av  a  2 s.  c o  m
@Test
public void testAggregatedPlateIndices() {

    for (Plate plate : arrayIndices) {

        int inputPercentile = 1 + random.nextInt(100);

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

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        BigDecimal aggregatedReturned = percentile.platesAggregated(plate, begin, end - begin, inputPercentile);

        for (Well well : plate) {
            resultList.addAll(well.toBigDecimal().subList(begin, end));
        }

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

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble);

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

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

/**
 * Tests the aggregated plate statistics method using the values between the indices.
 *///from ww w  . j  a  v a2 s .  co m
@Test
public void testAggregatedSetIndices() {

    for (Plate plate : arrayIndices) {

        int inputPercentile = 1 + random.nextInt(100);

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

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        BigDecimal aggregatedReturned = percentile.setsAggregated(plate.dataSet(), begin, end - begin,
                inputPercentile);

        for (Well well : plate) {
            resultList.addAll(well.toBigDecimal().subList(begin, end));
        }

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

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble);

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

From source file:com.github.jessemull.microflex.stat.statbiginteger.PercentileBigIntegerTest.java

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

    for (PlateBigInteger plate : array) {

        int inputPercentile = 1 + random.nextInt(100);

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

        for (WellBigInteger well : plate) {
            resultList.addAll(well.toBigDecimal());
        }

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

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble);

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

From source file:com.github.jessemull.microflex.stat.statbiginteger.PercentileBigIntegerTest.java

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

    for (PlateBigInteger plate : array) {

        int inputPercentile = 1 + random.nextInt(100);

        List<BigDecimal> resultList = new ArrayList<BigDecimal>();
        BigDecimal aggregatedReturned = percentile.setsAggregated(plate.dataSet(), inputPercentile);

        for (WellBigInteger well : plate) {
            resultList.addAll(well.toBigDecimal());
        }

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

        BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble);

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