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.microflexbigdecimal.stat.PercentileTest.java

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

    for (Plate plate : array) {

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

        Map<Well, BigDecimal> resultMap = new TreeMap<Well, BigDecimal>();
        Map<Well, BigDecimal> returnedMap = percentile.plate(plate, inputPercentile);

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

            BigDecimal result = new BigDecimal(resultDouble);

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

/**
 * Tests set calculation./* ww w.j a v a2s . c  om*/
 */
@Test
public void testSet() {

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

    for (Plate plate : array) {

        Map<Well, BigDecimal> resultMap = new TreeMap<Well, BigDecimal>();
        Map<Well, BigDecimal> returnedMap = percentile.set(plate.dataSet(), inputPercentile);

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

            BigDecimal result = new BigDecimal(resultDouble);

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

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

    for (Plate plate : array) {

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

        Map<Well, BigDecimal> resultMap = new TreeMap<Well, BigDecimal>();
        Map<Well, BigDecimal> returnedMap = percentile.plate(plate, inputPercentile);

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

            BigDecimal result = new BigDecimal(resultDouble);

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

/**
 * Tests set calculation.//from   w w w.j  av  a2 s  . c om
 */
@Test
public void testSet() {

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

    for (Plate plate : array) {

        Map<Well, BigDecimal> resultMap = new TreeMap<Well, BigDecimal>();
        Map<Well, BigDecimal> returnedMap = percentile.set(plate.dataSet(), inputPercentile);

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

            BigDecimal result = new BigDecimal(resultDouble);

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

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

    for (PlateBigDecimal plate : array) {

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

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

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

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

/**
 * Tests set calculation.//from w ww. j a v a2 s .c  o m
 */
@Test
public void testSet() {

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

    for (PlateBigDecimal plate : array) {

        Map<WellBigDecimal, BigDecimal> resultMap = new TreeMap<WellBigDecimal, BigDecimal>();
        Map<WellBigDecimal, BigDecimal> returnedMap = percentile.set(plate.dataSet(), inputPercentile);

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

            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.statbiginteger.PercentileBigIntegerTest.java

/**
 * Tests the plate statistics method.//from   www.j  ava 2  s. c  om
 */
@Test
public void testPlate() {

    for (PlateBigInteger plate : array) {

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

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

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

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

/**
 * Tests set calculation.//from w  w w .  j a  v  a  2 s.  c o  m
 */
@Test
public void testSet() {

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

    for (PlateBigInteger plate : array) {

        Map<WellBigInteger, BigDecimal> resultMap = new TreeMap<WellBigInteger, BigDecimal>();
        Map<WellBigInteger, BigDecimal> returnedMap = percentile.set(plate.dataSet(), inputPercentile);

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

            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.microflexbigdecimal.stat.PercentileTest.java

/**
 * Tests the aggregated plate statistics method.
 *///from   w  ww.jav a2 s  .c  o  m
@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.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.
 *///from w w  w . j  av a 2  s.  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.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]);
    }
}