List of usage examples for org.apache.commons.math3.stat.descriptive DescriptiveStatistics getGeometricMean
public double getGeometricMean()
From source file:com.github.jessemull.microflexdouble.stat.GeometricMeanWeightsTest.java
/** * Tests the aggregated plate statistics method using an array. *//*from w w w.j a va 2s . co m*/ @Test public void testAggregatedSetArray() { WellSet[] setArray = new WellSet[array.length]; for (int i = 0; i < setArray.length; i++) { setArray[i] = array[i].dataSet(); } Map<WellSet, Double> aggregatedReturnedMap = mean.setsAggregated(setArray, weights); Map<WellSet, Double> aggregatedResultMap = new TreeMap<WellSet, Double>(); for (WellSet set : setArray) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); for (Well well : set) { List<BigDecimal> input = well.toBigDecimal(); for (int i = 0; i < input.size(); i++) { resultList.add(input.get(i).multiply(new BigDecimal(weights[i]))); } } 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.getGeometricMean(); aggregatedResultMap.put(set, aggregatedResult); } for (WellSet 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.GeometricMeanDoubleWeightsTest.java
/** * Tests the aggregated plate statistics method using an array. */// w ww. java 2 s.c o m @Test public void testAggregatedSetArray() { WellSetDouble[] setArray = new WellSetDouble[array.length]; for (int i = 0; i < setArray.length; i++) { setArray[i] = array[i].dataSet(); } Map<WellSetDouble, Double> aggregatedReturnedMap = mean.setsAggregated(setArray, weights); Map<WellSetDouble, Double> aggregatedResultMap = new TreeMap<WellSetDouble, Double>(); for (WellSetDouble set : setArray) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); for (WellDouble well : set) { List<BigDecimal> input = well.toBigDecimal(); for (int i = 0; i < input.size(); i++) { resultList.add(input.get(i).multiply(new BigDecimal(weights[i]))); } } 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.getGeometricMean(); 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.microflexbigdecimal.stat.GeometricMeanTest.java
/** * Tests the aggregated plate statistics method. *//*ww w .ja va 2 s . com*/ @Test public void testAggregatedPlate() { for (Plate plate : array) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); BigDecimal aggregatedReturned = mean.platesAggregated(plate, mc); 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.getGeometricMean(); BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble); BigDecimal[] corrected = correctRoundingErrors(aggregatedResult, aggregatedReturned); assertEquals(corrected[0], corrected[1]); } }
From source file:com.github.jessemull.microflexbigdecimal.stat.GeometricMeanTest.java
/** * Tests the aggregated plate statistics method. *//*from ww w . ja v a 2s . c o m*/ @Test public void testAggregatedSet() { for (Plate plate : array) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); BigDecimal aggregatedReturned = mean.setsAggregated(plate.dataSet(), mc); 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.getGeometricMean(); BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble); BigDecimal[] corrected = correctRoundingErrors(aggregatedResult, aggregatedReturned); assertEquals(corrected[0], corrected[1]); } }
From source file:com.github.jessemull.microflex.stat.statinteger.GeometricMeanIntegerWeightsTest.java
/** * Tests the aggregated plate statistics method using the values between the indices. *///from ww w .j ava 2s . com @Test public void testAggregatedPlateIndices() { for (PlateInteger plate : arrayIndices) { int begin = random.nextInt(plate.first().size() - 4); int end = begin + random.nextInt(3) + 3; List<BigDecimal> resultList = new ArrayList<BigDecimal>(); double aggregatedReturned = Precision .round(mean.platesAggregated(plate, weightsIndices, begin, end - begin), precision); for (WellInteger well : plate) { List<BigDecimal> input = well.toBigDecimal().subList(begin, end); for (int i = 0; i < input.size(); i++) { resultList.add(input.get(i).multiply(new BigDecimal(weightsIndices[i]))); } } 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.getGeometricMean(), precision); assertTrue(resultAggregated == aggregatedReturned); } }
From source file:com.github.jessemull.microflex.stat.statinteger.GeometricMeanIntegerWeightsTest.java
/** * Tests the aggregated plate statistics method using the values between the indices. *///from w w w . j a v a 2 s . c o m @Test public void testAggregatedSetIndices() { for (PlateInteger plate : arrayIndices) { int begin = random.nextInt(plate.first().size() - 4); int end = begin + random.nextInt(3) + 3; List<BigDecimal> resultList = new ArrayList<BigDecimal>(); double aggregatedReturned = Precision .round(mean.setsAggregated(plate.dataSet(), weightsIndices, begin, end - begin), precision); for (WellInteger well : plate) { List<BigDecimal> input = well.toBigDecimal().subList(begin, end); for (int i = 0; i < input.size(); i++) { resultList.add(input.get(i).multiply(new BigDecimal(weightsIndices[i]))); } } 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.getGeometricMean(), precision); assertTrue(resultAggregated == aggregatedReturned); } }
From source file:com.github.jessemull.microflex.stat.statinteger.GeometricMeanIntegerWeightsTest.java
/** * Tests the aggregated plate statistics method using the values between the indices of * the collection.//from www . jav a 2 s . co m */ @Test public void testAggregatedSetCollectionIndices() { int begin = random.nextInt(arrayIndices[0].first().size() - 4); int end = begin + random.nextInt(3) + 3; List<WellSetInteger> collection = new ArrayList<WellSetInteger>(); for (PlateInteger plate : arrayIndices) { collection.add(plate.dataSet()); } Map<WellSetInteger, Double> aggregatedReturnedMap = mean.setsAggregated(collection, weightsIndices, begin, end - begin); Map<WellSetInteger, Double> aggregatedResultMap = new TreeMap<WellSetInteger, Double>(); for (WellSetInteger set : collection) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); for (WellInteger well : set) { List<BigDecimal> input = well.toBigDecimal().subList(begin, end); for (int i = 0; i < input.size(); i++) { resultList.add(input.get(i).multiply(new BigDecimal(weightsIndices[i]))); } } 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.getGeometricMean(); 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.GeometricMeanIntegerWeightsTest.java
/** * Tests the aggregated plate statistics method using the values between the indices of * the array.//w w w . ja va 2s.c o m */ @Test public void testAggregatedSetArrayIndices() { int begin = random.nextInt(arrayIndices[0].first().size() - 4); int end = begin + random.nextInt(3) + 3; WellSetInteger[] setArrayIndices = new WellSetInteger[arrayIndices.length]; for (int i = 0; i < setArrayIndices.length; i++) { setArrayIndices[i] = arrayIndices[i].dataSet(); } Map<WellSetInteger, Double> aggregatedReturnedMap = mean.setsAggregated(setArrayIndices, weightsIndices, begin, end - begin); Map<WellSetInteger, Double> aggregatedResultMap = new TreeMap<WellSetInteger, Double>(); for (WellSetInteger set : setArrayIndices) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); for (WellInteger well : set) { List<BigDecimal> input = well.toBigDecimal().subList(begin, end); for (int i = 0; i < input.size(); i++) { resultList.add(input.get(i).multiply(new BigDecimal(weightsIndices[i]))); } } 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.getGeometricMean(); 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.microflexbiginteger.stat.GeometricMeanTest.java
/** * Tests the aggregated plate statistics method. *//*w w w. j av a 2 s .co m*/ @Test public void testAggregatedPlate() { for (Plate plate : array) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); BigDecimal aggregatedReturned = mean.platesAggregated(plate, mc); 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.getGeometricMean(); BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble); BigDecimal[] corrected = correctRoundingErrors(aggregatedResult, aggregatedReturned); assertEquals(corrected[0], corrected[1]); } }
From source file:com.github.jessemull.microflexbiginteger.stat.GeometricMeanTest.java
/** * Tests the aggregated plate statistics method. *//*from ww w . j a v a2s . c o m*/ @Test public void testAggregatedSet() { for (Plate plate : array) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); BigDecimal aggregatedReturned = mean.setsAggregated(plate.dataSet(), mc); 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.getGeometricMean(); BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble); BigDecimal[] corrected = correctRoundingErrors(aggregatedResult, aggregatedReturned); assertEquals(corrected[0], corrected[1]); } }