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