List of usage examples for org.apache.commons.math3.stat.descriptive DescriptiveStatistics getSum
public double getSum()
From source file:com.github.jessemull.microflexbiginteger.stat.SumWeightsTest.java
/** * Tests the aggregated plate statistics method using the values between the indices of * the array./*w ww .j a v a 2 s .c om*/ */ @Test public void testAggregatedPlateArrayIndices() { int begin = random.nextInt(arrayIndices[0].first().size() - 4); int end = begin + random.nextInt(3) + 3; Map<Plate, BigDecimal> aggregatedReturnedMap = sum.platesAggregated(arrayIndices, weightsIndices, begin, end - begin, mc); Map<Plate, BigDecimal> aggregatedResultMap = new TreeMap<Plate, BigDecimal>(); for (Plate plate : arrayIndices) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); for (Well 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 resultAggregatedDouble = statAggregated.getSum(); BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc); aggregatedResultMap.put(plate, aggregatedResult); } for (Plate plate : arrayIndices) { BigDecimal result = aggregatedResultMap.get(plate); BigDecimal returned = aggregatedReturnedMap.get(plate); BigDecimal[] corrected = correctRoundingErrors(result, returned); assertEquals(corrected[0], corrected[1]); } }
From source file:com.github.jessemull.microflex.stat.statbiginteger.SumBigIntegerWeightsTest.java
/** * Tests the plate statistics method using the values between the indices. *//*from ww w .java 2 s . com*/ @Test public void testPlateIndices() { for (PlateBigInteger plate : arrayIndices) { int begin = random.nextInt(plate.first().size() - 4); int end = begin + random.nextInt(3) + 3; Map<WellBigInteger, BigDecimal> resultMap = new TreeMap<WellBigInteger, BigDecimal>(); Map<WellBigInteger, BigDecimal> returnedMap = sum.plate(plate, ArrayUtils.subarray(weightsIndices, begin, end), begin, end - begin, mc); for (WellBigInteger well : plate) { double[] input = new double[well.size()]; int index = 0; for (BigInteger bi : well) { input[index] = bi.doubleValue() * weightsIndices[index]; index++; } DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end)); double resultDouble = stat.getSum(); BigDecimal result = new BigDecimal(resultDouble, mc); 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.SumBigIntegerWeightsTest.java
/** * Tests the aggregated plate statistics method using the values between the indices of * the collection.//ww w. ja v a2s. c o m */ @Test public void testAggregatedPlateCollectionIndices() { int begin = random.nextInt(arrayIndices[0].first().size() - 4); int end = begin + random.nextInt(3) + 3; List<PlateBigInteger> collection = Arrays.asList(arrayIndices); Map<PlateBigInteger, BigDecimal> aggregatedReturnedMap = sum.platesAggregated(collection, weightsIndices, begin, end - begin, mc); Map<PlateBigInteger, BigDecimal> aggregatedResultMap = new TreeMap<PlateBigInteger, BigDecimal>(); for (PlateBigInteger plate : collection) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); for (WellBigInteger 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 resultAggregatedDouble = statAggregated.getSum(); BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc); aggregatedResultMap.put(plate, aggregatedResult); } for (PlateBigInteger plate : collection) { BigDecimal result = aggregatedResultMap.get(plate); BigDecimal returned = aggregatedReturnedMap.get(plate); BigDecimal[] corrected = correctRoundingErrors(result, returned); assertEquals(corrected[0], corrected[1]); } }
From source file:com.github.jessemull.microflex.stat.statbiginteger.SumBigIntegerWeightsTest.java
/** * Tests set calculation using indices.//from w w w . jav a 2s .c o m */ @Test public void testSetIndices() { for (PlateBigInteger plate : arrayIndices) { int begin = random.nextInt(plate.first().size() - 4); int end = begin + random.nextInt(3) + 3; Map<WellBigInteger, BigDecimal> resultMap = new TreeMap<WellBigInteger, BigDecimal>(); Map<WellBigInteger, BigDecimal> returnedMap = sum.set(plate.dataSet(), ArrayUtils.subarray(weightsIndices, begin, end), begin, end - begin, mc); for (WellBigInteger well : plate) { double[] input = new double[well.size()]; int index = 0; for (BigInteger bi : well) { input[index] = bi.doubleValue() * weightsIndices[index]; index++; } DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end)); double resultDouble = stat.getSum(); BigDecimal result = new BigDecimal(resultDouble, mc); 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.microflexbiginteger.stat.SumWeightsTest.java
/** * Tests the plate statistics method using the values between the indices. *//*w ww . jav a 2 s. c o m*/ @Test public void testPlateIndices() { for (Plate plate : arrayIndices) { int begin = random.nextInt(plate.first().size() - 4); int end = begin + random.nextInt(3) + 3; Map<Well, BigDecimal> resultMap = new TreeMap<Well, BigDecimal>(); Map<Well, BigDecimal> returnedMap = sum.plate(plate, ArrayUtils.subarray(weightsIndices, begin, end), begin, end - begin, mc); for (Well well : plate) { double[] input = new double[well.size()]; int index = 0; for (BigInteger bi : well) { input[index] = bi.doubleValue() * weightsIndices[index]; index++; } DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end)); double resultDouble = stat.getSum(); BigDecimal result = new BigDecimal(resultDouble, mc); 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.SumWeightsTest.java
/** * Tests the aggregated plate statistics method using the values between the indices of * the collection.// w ww . ja v a2 s . com */ @Test public void testAggregatedPlateCollectionIndices() { int begin = random.nextInt(arrayIndices[0].first().size() - 4); int end = begin + random.nextInt(3) + 3; List<Plate> collection = Arrays.asList(arrayIndices); Map<Plate, BigDecimal> aggregatedReturnedMap = sum.platesAggregated(collection, weightsIndices, begin, end - begin, mc); Map<Plate, BigDecimal> aggregatedResultMap = new TreeMap<Plate, BigDecimal>(); for (Plate plate : collection) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); for (Well 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 resultAggregatedDouble = statAggregated.getSum(); BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc); aggregatedResultMap.put(plate, aggregatedResult); } for (Plate plate : collection) { BigDecimal result = aggregatedResultMap.get(plate); BigDecimal returned = aggregatedReturnedMap.get(plate); BigDecimal[] corrected = correctRoundingErrors(result, returned); assertEquals(corrected[0], corrected[1]); } }
From source file:com.github.jessemull.microflexbiginteger.stat.SumWeightsTest.java
/** * Tests set calculation using indices.//w w w. j a v a2 s.c o m */ @Test public void testSetIndices() { for (Plate plate : arrayIndices) { int begin = random.nextInt(plate.first().size() - 4); int end = begin + random.nextInt(3) + 3; Map<Well, BigDecimal> resultMap = new TreeMap<Well, BigDecimal>(); Map<Well, BigDecimal> returnedMap = sum.set(plate.dataSet(), ArrayUtils.subarray(weightsIndices, begin, end), begin, end - begin, mc); for (Well well : plate) { double[] input = new double[well.size()]; int index = 0; for (BigInteger bi : well) { input[index] = bi.doubleValue() * weightsIndices[index]; index++; } DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end)); double resultDouble = stat.getSum(); BigDecimal result = new BigDecimal(resultDouble, mc); 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.SumBigDecimalWeightsTest.java
/** * Tests the aggregated plate statistics method using the values between the indices of * the array./* www. j a va2 s . co m*/ */ @Test public void testAggregatedPlateArrayIndices() { int begin = random.nextInt(arrayIndices[0].first().size() - 4); int end = begin + random.nextInt(3) + 3; Map<PlateBigDecimal, BigDecimal> aggregatedReturnedMap = sum.platesAggregated(arrayIndices, weightsIndices, begin, end - begin, mc); Map<PlateBigDecimal, BigDecimal> aggregatedResultMap = new TreeMap<PlateBigDecimal, BigDecimal>(); for (PlateBigDecimal plate : arrayIndices) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); for (WellBigDecimal well : plate) { List<BigDecimal> input = well.data().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 resultAggregatedDouble = statAggregated.getSum(); BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc); aggregatedResultMap.put(plate, aggregatedResult); } for (PlateBigDecimal plate : arrayIndices) { BigDecimal result = aggregatedResultMap.get(plate); BigDecimal returned = aggregatedReturnedMap.get(plate); BigDecimal[] corrected = correctRoundingErrors(result, returned); assertEquals(corrected[0], corrected[1]); } }
From source file:com.github.jessemull.microflex.stat.statbiginteger.SumBigIntegerWeightsTest.java
/** * Tests the aggregated plate statistics method using a collection. *//* w w w .j a va2 s . com*/ @Test public void testAggregatedSetCollection() { List<WellSetBigInteger> collection = new ArrayList<WellSetBigInteger>(); for (PlateBigInteger plate : array) { collection.add(plate.dataSet()); } Map<WellSetBigInteger, BigDecimal> aggregatedReturnedMap = sum.setsAggregated(collection, weights, mc); Map<WellSetBigInteger, BigDecimal> aggregatedResultMap = new TreeMap<WellSetBigInteger, BigDecimal>(); for (WellSetBigInteger set : collection) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); for (WellBigInteger 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 resultAggregatedDouble = statAggregated.getSum(); BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc); aggregatedResultMap.put(set, aggregatedResult); } for (WellSetBigInteger set : collection) { BigDecimal result = aggregatedResultMap.get(set); BigDecimal returned = aggregatedReturnedMap.get(set); BigDecimal[] corrected = correctRoundingErrors(result, returned); assertEquals(corrected[0], corrected[1]); } }
From source file:com.github.jessemull.microflexbigdecimal.stat.SumWeightsTest.java
/** * Tests the aggregated plate statistics method using the values between the indices of * the array./*w w w .j a va 2 s . com*/ */ @Test public void testAggregatedPlateArrayIndices() { int begin = random.nextInt(arrayIndices[0].first().size() - 4); int end = begin + random.nextInt(3) + 3; Map<Plate, BigDecimal> aggregatedReturnedMap = sum.platesAggregated(arrayIndices, weightsIndices, begin, end - begin, mc); Map<Plate, BigDecimal> aggregatedResultMap = new TreeMap<Plate, BigDecimal>(); for (Plate plate : arrayIndices) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); for (Well well : plate) { List<BigDecimal> input = well.data().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 resultAggregatedDouble = statAggregated.getSum(); BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc); aggregatedResultMap.put(plate, aggregatedResult); } for (Plate plate : arrayIndices) { BigDecimal result = aggregatedResultMap.get(plate); BigDecimal returned = aggregatedReturnedMap.get(plate); BigDecimal[] corrected = correctRoundingErrors(result, returned); assertEquals(corrected[0], corrected[1]); } }