List of usage examples for org.apache.commons.math3.stat.descriptive DescriptiveStatistics getPercentile
public double getPercentile(double p) throws MathIllegalStateException, MathIllegalArgumentException
From source file:com.github.jessemull.microflex.stat.statdouble.PercentileDoubleTest.java
/** * Tests the aggregated plate statistics method using a collection. *//*from w ww . j a v a2s. c o m*/ @Test public void testAggregatedSetCollection() { int inputPercentile = 1 + random.nextInt(100); List<WellSetDouble> collection = new ArrayList<WellSetDouble>(); for (PlateDouble plate : array) { collection.add(plate.dataSet()); } Map<WellSetDouble, Double> aggregatedReturnedMap = percentile.setsAggregated(collection, inputPercentile); Map<WellSetDouble, Double> aggregatedResultMap = new TreeMap<WellSetDouble, Double>(); for (WellSetDouble set : collection) { List<Double> resultList = new ArrayList<Double>(); for (WellDouble well : set) { 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 aggregatedResult = statAggregated.getPercentile(inputPercentile); aggregatedResultMap.put(set, aggregatedResult); } for (WellSetDouble set : collection) { double result = Precision.round(aggregatedResultMap.get(set), precision); double returned = Precision.round(aggregatedReturnedMap.get(set), precision); assertTrue(result == returned); } }
From source file:com.github.jessemull.microflex.stat.statinteger.PercentileIntegerTest.java
/** * Tests the aggregated plate statistics method. *//*w ww. j a v a 2 s. com*/ @Test public void testAggregatedPlate() { for (PlateInteger plate : array) { int inputPercentile = 1 + random.nextInt(100); List<Double> resultList = new ArrayList<Double>(); double aggregatedReturned = Precision.round(percentile.platesAggregated(plate, inputPercentile), 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).doubleValue(); } DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated); double resultAggregated = Precision.round(statAggregated.getPercentile(inputPercentile), precision); assertTrue(resultAggregated == aggregatedReturned); } }
From source file:com.github.jessemull.microflex.stat.statinteger.PercentileIntegerTest.java
/** * Tests the aggregated plate statistics method using the values between the indices of * the collection.//ww w. j a v a2s . c o m */ @Test public void testAggregatedPlateCollectionIndices() { 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<PlateInteger> collection = Arrays.asList(arrayIndices); Map<PlateInteger, Double> aggregatedReturnedMap = percentile.platesAggregated(collection, begin, end - begin, inputPercentile); Map<PlateInteger, Double> aggregatedResultMap = new TreeMap<PlateInteger, Double>(); for (PlateInteger plate : collection) { List<Double> resultList = new ArrayList<Double>(); for (WellInteger well : plate) { resultList.addAll(well.toDouble().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 aggregatedResult = statAggregated.getPercentile(inputPercentile); aggregatedResultMap.put(plate, aggregatedResult); } for (PlateInteger plate : collection) { double result = Precision.round(aggregatedResultMap.get(plate), precision); double returned = Precision.round(aggregatedReturnedMap.get(plate), precision); assertTrue(result == returned); } }
From source file:com.github.jessemull.microflex.stat.statinteger.PercentileIntegerTest.java
/** * Tests the aggregated plate statistics method. *///from w w w. ja va2s . co m @Test public void testAggregatedSet() { for (PlateInteger plate : array) { int inputPercentile = 1 + random.nextInt(100); List<Double> resultList = new ArrayList<Double>(); double aggregatedReturned = Precision.round(percentile.setsAggregated(plate.dataSet(), inputPercentile), 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).doubleValue(); } DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated); double resultAggregated = Precision.round(statAggregated.getPercentile(inputPercentile), precision); assertTrue(resultAggregated == aggregatedReturned); } }
From source file:com.github.jessemull.microflex.stat.statinteger.PercentileIntegerTest.java
/** * Tests the aggregated plate statistics method using an array. *///ww w .j a v a 2 s.c o m @Test public void testAggregatedSetArray() { int inputPercentile = 1 + random.nextInt(100); WellSetInteger[] setArray = new WellSetInteger[array.length]; for (int i = 0; i < setArray.length; i++) { setArray[i] = array[i].dataSet(); } Map<WellSetInteger, Double> aggregatedReturnedMap = percentile.setsAggregated(setArray, inputPercentile); Map<WellSetInteger, Double> aggregatedResultMap = new TreeMap<WellSetInteger, Double>(); for (WellSetInteger set : setArray) { List<Double> resultList = new ArrayList<Double>(); for (WellInteger well : set) { resultList.addAll(well.toDouble()); } 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 aggregatedResult = statAggregated.getPercentile(inputPercentile); aggregatedResultMap.put(set, aggregatedResult); } for (WellSetInteger set : setArray) { double result = Precision.round(aggregatedResultMap.get(set), precision); double returned = Precision.round(aggregatedReturnedMap.get(set), precision); assertTrue(result == returned); } }
From source file:com.github.jessemull.microflex.stat.statdouble.PercentileDoubleTest.java
/** * Tests the aggregated plate statistics method. */// w ww . j a va 2 s . c o m @Test public void testAggregatedPlate() { for (PlateDouble plate : array) { int inputPercentile = 1 + random.nextInt(100); List<Double> resultList = new ArrayList<Double>(); double aggregatedReturned = Precision.round(percentile.platesAggregated(plate, inputPercentile), 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).doubleValue(); } DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated); double resultAggregated = Precision.round(statAggregated.getPercentile(inputPercentile), precision); assertTrue(resultAggregated == aggregatedReturned); } }
From source file:com.github.jessemull.microflex.stat.statdouble.PercentileDoubleTest.java
/** * Tests the aggregated plate statistics method using the values between the indices of * the collection./*from w ww . j a v a 2 s . c om*/ */ @Test public void testAggregatedPlateCollectionIndices() { 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<PlateDouble> collection = Arrays.asList(arrayIndices); Map<PlateDouble, Double> aggregatedReturnedMap = percentile.platesAggregated(collection, begin, end - begin, inputPercentile); Map<PlateDouble, Double> aggregatedResultMap = new TreeMap<PlateDouble, Double>(); for (PlateDouble plate : collection) { List<Double> resultList = new ArrayList<Double>(); for (WellDouble 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 aggregatedResult = statAggregated.getPercentile(inputPercentile); aggregatedResultMap.put(plate, aggregatedResult); } for (PlateDouble plate : collection) { double result = Precision.round(aggregatedResultMap.get(plate), precision); double returned = Precision.round(aggregatedReturnedMap.get(plate), precision); assertTrue(result == returned); } }
From source file:com.github.jessemull.microflex.stat.statdouble.PercentileDoubleTest.java
/** * Tests the aggregated plate statistics method. *//* ww w . j av a2 s.c om*/ @Test public void testAggregatedSet() { for (PlateDouble plate : array) { int inputPercentile = 1 + random.nextInt(100); List<Double> resultList = new ArrayList<Double>(); double aggregatedReturned = Precision.round(percentile.setsAggregated(plate.dataSet(), inputPercentile), 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).doubleValue(); } DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated); double resultAggregated = Precision.round(statAggregated.getPercentile(inputPercentile), precision); assertTrue(resultAggregated == aggregatedReturned); } }
From source file:com.github.jessemull.microflex.stat.statdouble.PercentileDoubleTest.java
/** * Tests the aggregated plate statistics method using an array. *///from ww w .j av a 2 s . c om @Test public void testAggregatedSetArray() { int inputPercentile = 1 + random.nextInt(100); WellSetDouble[] setArray = new WellSetDouble[array.length]; for (int i = 0; i < setArray.length; i++) { setArray[i] = array[i].dataSet(); } Map<WellSetDouble, Double> aggregatedReturnedMap = percentile.setsAggregated(setArray, inputPercentile); Map<WellSetDouble, Double> aggregatedResultMap = new TreeMap<WellSetDouble, Double>(); for (WellSetDouble set : setArray) { List<Double> resultList = new ArrayList<Double>(); for (WellDouble well : set) { 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 aggregatedResult = statAggregated.getPercentile(inputPercentile); aggregatedResultMap.put(set, aggregatedResult); } for (WellSetDouble set : setArray) { double result = Precision.round(aggregatedResultMap.get(set), precision); double returned = Precision.round(aggregatedReturnedMap.get(set), precision); assertTrue(result == returned); } }
From source file:com.github.jessemull.microflexdouble.stat.PercentileTest.java
/** * Tests the plate statistics method using the values between the indices. *//* w ww . j av a 2 s . c o m*/ @Test public void testPlateIndices() { 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); Map<Well, Double> resultMap = new TreeMap<Well, Double>(); Map<Well, Double> returnedMap = percentile.plate(plate, begin, end - begin, inputPercentile); for (Well well : plate) { double[] input = new double[well.size()]; int index = 0; for (double db : well) { input[index++] = db; } DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end)); double result = stat.getPercentile(inputPercentile); resultMap.put(well, result); } for (Well well : plate) { double result = Precision.round(resultMap.get(well), precision); double returned = Precision.round(returnedMap.get(well), precision); assertTrue(result == returned); } } }