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.microflexdouble.stat.PercentileTest.java
/** * Tests the aggregated plate statistics method using the values between the indices of * the collection./*from w w w . j a v a2 s . com*/ */ @Test public void testAggregatedSetCollectionIndices() { 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<WellSet> collection = new ArrayList<WellSet>(); for (Plate plate : arrayIndices) { collection.add(plate.dataSet()); } Map<WellSet, Double> aggregatedReturnedMap = percentile.setsAggregated(collection, begin, end - begin, inputPercentile); Map<WellSet, Double> aggregatedResultMap = new TreeMap<WellSet, Double>(); for (WellSet set : collection) { List<Double> resultList = new ArrayList<Double>(); for (Well well : set) { 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(set, aggregatedResult); } for (WellSet 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.microflexdouble.stat.PercentileTest.java
/** * Tests the aggregated plate statistics method using the values between the indices of * the array.// www . j a v a 2s . com */ @Test public void testAggregatedSetArrayIndices() { 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); WellSet[] setArrayIndices = new WellSet[arrayIndices.length]; for (int i = 0; i < setArrayIndices.length; i++) { setArrayIndices[i] = arrayIndices[i].dataSet(); } Map<WellSet, Double> aggregatedReturnedMap = percentile.setsAggregated(setArrayIndices, begin, end - begin, inputPercentile); Map<WellSet, Double> aggregatedResultMap = new TreeMap<WellSet, Double>(); for (WellSet set : setArrayIndices) { List<Double> resultList = new ArrayList<Double>(); for (Well well : set) { 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(set, aggregatedResult); } for (WellSet plate : setArrayIndices) { double result = Precision.round(aggregatedResultMap.get(plate), precision); double returned = Precision.round(aggregatedReturnedMap.get(plate), precision); assertTrue(result == returned); } }
From source file:de.iisys.schub.processMining.similarity.AlgoController.java
private String showDocMetaData(List<Double> cosineSimValues) { DescriptiveStatistics stat = new DescriptiveStatistics(); for (int i = 0; i < cosineSimValues.size(); i++) { stat.addValue(cosineSimValues.get(i)); }/*from w w w .j a v a2 s.c o m*/ double min = Math.round(stat.getMin() * 1000) / 1000.0; double max = Math.round(stat.getMax() * 1000) / 1000.0; double arithMean = Math.round(stat.getMean() * 10000) / 10000.0; double percentile = Math.round(stat.getPercentile(PERCENTILE) * 1000) / 1000.0; DecimalFormat df = new DecimalFormat("#00.00"); String meta = "Min: " + df.format(min * 100) + " %" + ", Max: " + df.format(max * 100) + " %" + ", Arith. Mean: " + df.format(arithMean * 100) + " %" + ", Percentile (" + PERCENTILE + " %): " + df.format(percentile * 100) + " %"; return meta; }
From source file:com.github.jessemull.microflex.stat.statdouble.PercentileDoubleTest.java
/** * Tests set calculation using indices.// w w w . j a v a 2 s. com */ @Test public void testSetIndices() { for (PlateDouble 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<WellDouble, Double> resultMap = new TreeMap<WellDouble, Double>(); Map<WellDouble, Double> returnedMap = percentile.set(plate.dataSet(), begin, end - begin, inputPercentile); for (WellDouble 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 (WellDouble well : plate) { double result = Precision.round(resultMap.get(well), precision); double returned = Precision.round(returnedMap.get(well), precision); assertTrue(result == returned); } } }
From source file:com.github.jessemull.microflex.stat.statinteger.PercentileIntegerTest.java
/** * Tests the aggregated plate statistics method using the values between the indices. *///from w w w .j ava 2 s . co m @Test public void testAggregatedPlateIndices() { for (PlateInteger 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<Double> resultList = new ArrayList<Double>(); double aggregatedReturned = Precision .round(percentile.platesAggregated(plate, begin, end - begin, inputPercentile), precision); 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 = Precision.round(statAggregated.getPercentile(inputPercentile), precision); assertTrue(aggregatedResult == aggregatedReturned); } }
From source file:com.github.jessemull.microflex.stat.statinteger.PercentileIntegerTest.java
/** * Tests the aggregated plate statistics method using the values between the indices. *//*w ww . j a va 2 s .com*/ @Test public void testAggregatedSetIndices() { for (PlateInteger 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<Double> resultList = new ArrayList<Double>(); double aggregatedReturned = Precision.round( percentile.setsAggregated(plate.dataSet(), begin, end - begin, inputPercentile), precision); 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 = Precision.round(statAggregated.getPercentile(inputPercentile), precision); assertTrue(aggregatedResult == 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.//from www . j a v a 2s.c om */ @Test public void testAggregatedSetCollectionIndices() { 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<WellSetInteger> collection = new ArrayList<WellSetInteger>(); for (PlateInteger plate : arrayIndices) { collection.add(plate.dataSet()); } Map<WellSetInteger, Double> aggregatedReturnedMap = percentile.setsAggregated(collection, begin, end - begin, inputPercentile); Map<WellSetInteger, Double> aggregatedResultMap = new TreeMap<WellSetInteger, Double>(); for (WellSetInteger set : collection) { List<Double> resultList = new ArrayList<Double>(); for (WellInteger well : set) { 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(set, aggregatedResult); } for (WellSetInteger 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 using the values between the indices of * the array.//from w w w.j a v a 2 s .c om */ @Test public void testAggregatedSetArrayIndices() { 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); WellSetInteger[] setArrayIndices = new WellSetInteger[arrayIndices.length]; for (int i = 0; i < setArrayIndices.length; i++) { setArrayIndices[i] = arrayIndices[i].dataSet(); } Map<WellSetInteger, Double> aggregatedReturnedMap = percentile.setsAggregated(setArrayIndices, begin, end - begin, inputPercentile); Map<WellSetInteger, Double> aggregatedResultMap = new TreeMap<WellSetInteger, Double>(); for (WellSetInteger set : setArrayIndices) { List<Double> resultList = new ArrayList<Double>(); for (WellInteger well : set) { 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(set, aggregatedResult); } for (WellSetInteger plate : setArrayIndices) { 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 using the values between the indices. *//*w w w. ja v a 2 s. c o m*/ @Test public void testAggregatedPlateIndices() { for (PlateDouble 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<Double> resultList = new ArrayList<Double>(); double aggregatedReturned = Precision .round(percentile.platesAggregated(plate, begin, end - begin, inputPercentile), precision); 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 = Precision.round(statAggregated.getPercentile(inputPercentile), precision); assertTrue(aggregatedResult == aggregatedReturned); } }
From source file:com.github.jessemull.microflex.stat.statdouble.PercentileDoubleTest.java
/** * Tests the aggregated plate statistics method using the values between the indices. *//*from ww w . ja v a 2s. co m*/ @Test public void testAggregatedSetIndices() { for (PlateDouble 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<Double> resultList = new ArrayList<Double>(); double aggregatedReturned = Precision.round( percentile.setsAggregated(plate.dataSet(), begin, end - begin, inputPercentile), precision); 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 = Precision.round(statAggregated.getPercentile(inputPercentile), precision); assertTrue(aggregatedResult == aggregatedReturned); } }