List of usage examples for org.apache.commons.math3.stat.descriptive DescriptiveStatistics getSumsq
public double getSumsq()
From source file:com.github.jessemull.microflexbiginteger.stat.SumOfSquaresWeightsTest.java
/** * Tests the aggregated plate statistics method. *///from w w w .ja va2 s . c o m @Test public void testAggregatedSet() { for (Plate plate : array) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); BigDecimal aggregatedReturned = sum.setsAggregated(plate.dataSet(), weights, mc); 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.getSumsq(); BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc); BigDecimal[] corrected = correctRoundingErrors(aggregatedResult, aggregatedReturned); assertEquals(corrected[0], corrected[1]); } }
From source file:com.github.jessemull.microflex.stat.statbigdecimal.SumOfSquaresBigDecimalWeightsTest.java
/** * Tests the aggregated plate statistics method. */// www . jav a 2s .c o m @Test public void testAggregatedPlate() { for (PlateBigDecimal plate : array) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); BigDecimal aggregatedReturned = sum.platesAggregated(plate, weights, mc); 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.getSumsq(); BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc); BigDecimal[] corrected = correctRoundingErrors(aggregatedResult, aggregatedReturned); assertEquals(corrected[0], corrected[1]); } }
From source file:com.github.jessemull.microflex.stat.statbigdecimal.SumOfSquaresBigDecimalWeightsTest.java
/** * Tests the aggregated plate statistics method. *//* ww w . ja v a 2 s.c om*/ @Test public void testAggregatedSet() { for (PlateBigDecimal plate : array) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); BigDecimal aggregatedReturned = sum.setsAggregated(plate.dataSet(), weights, mc); 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.getSumsq(); BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc); BigDecimal[] corrected = correctRoundingErrors(aggregatedResult, aggregatedReturned); assertEquals(corrected[0], corrected[1]); } }
From source file:com.github.jessemull.microflexbigdecimal.stat.SumOfSquaresWeightsTest.java
/** * Tests the aggregated plate statistics method. *///w ww .java 2 s . co m @Test public void testAggregatedPlate() { for (Plate plate : array) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); BigDecimal aggregatedReturned = sum.platesAggregated(plate, weights, mc); 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.getSumsq(); BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc); BigDecimal[] corrected = correctRoundingErrors(aggregatedResult, aggregatedReturned); assertEquals(corrected[0], corrected[1]); } }
From source file:com.github.jessemull.microflexbigdecimal.stat.SumOfSquaresWeightsTest.java
/** * Tests the aggregated plate statistics method. *//* w w w. j a va 2 s. co m*/ @Test public void testAggregatedSet() { for (Plate plate : array) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); BigDecimal aggregatedReturned = sum.setsAggregated(plate.dataSet(), weights, mc); 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.getSumsq(); BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc); BigDecimal[] corrected = correctRoundingErrors(aggregatedResult, aggregatedReturned); assertEquals(corrected[0], corrected[1]); } }
From source file:com.github.jessemull.microflex.stat.statbiginteger.SumOfSquaresBigIntegerWeightsTest.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 testAggregatedPlateIndices() { for (PlateBigInteger plate : arrayIndices) { int begin = random.nextInt(plate.first().size() - 4); int end = begin + random.nextInt(3) + 3; List<BigDecimal> resultList = new ArrayList<BigDecimal>(); BigDecimal aggregatedReturned = sum.platesAggregated(plate, weightsIndices, begin, end - begin, mc); 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.getSumsq(); BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc); BigDecimal[] corrected = correctRoundingErrors(aggregatedResult, aggregatedReturned); assertEquals(corrected[0], corrected[1]); } }
From source file:com.github.jessemull.microflexbiginteger.stat.SumOfSquaresWeightsTest.java
/** * Tests the aggregated plate statistics method using the values between the indices. *///w w w. j ava 2 s . c o m @Test public void testAggregatedPlateIndices() { for (Plate plate : arrayIndices) { int begin = random.nextInt(plate.first().size() - 4); int end = begin + random.nextInt(3) + 3; List<BigDecimal> resultList = new ArrayList<BigDecimal>(); BigDecimal aggregatedReturned = sum.platesAggregated(plate, weightsIndices, begin, end - begin, mc); 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.getSumsq(); BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc); BigDecimal[] corrected = correctRoundingErrors(aggregatedResult, aggregatedReturned); assertEquals(corrected[0], corrected[1]); } }
From source file:com.github.jessemull.microflex.stat.statbiginteger.SumOfSquaresBigIntegerWeightsTest.java
/** * Tests the aggregated plate statistics method using the values between the indices. *//*from w ww. j av a 2 s . c om*/ @Test public void testAggregatedSetIndices() { for (PlateBigInteger plate : arrayIndices) { int begin = random.nextInt(plate.first().size() - 4); int end = begin + random.nextInt(3) + 3; List<BigDecimal> resultList = new ArrayList<BigDecimal>(); BigDecimal aggregatedReturned = sum.setsAggregated(plate.dataSet(), weightsIndices, begin, end - begin, mc); 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.getSumsq(); BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc); BigDecimal[] corrected = correctRoundingErrors(aggregatedResult, aggregatedReturned); assertEquals(corrected[0], corrected[1]); } }
From source file:com.github.jessemull.microflex.stat.statbiginteger.SumOfSquaresBigIntegerWeightsTest.java
/** * Tests well calculation using indices. *//*from ww w . ja va2 s. c o m*/ @Test public void testWellIndices() { for (PlateBigInteger plate : arrayIndices) { for (WellBigInteger well : plate) { double[] input = new double[well.size()]; int index = 0; for (BigInteger bi : well) { input[index] = bi.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.getSumsq(); 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.microflexbiginteger.stat.SumOfSquaresWeightsTest.java
/** * Tests the aggregated plate statistics method using the values between the indices. *///w ww .java 2s . co m @Test public void testAggregatedSetIndices() { for (Plate plate : arrayIndices) { int begin = random.nextInt(plate.first().size() - 4); int end = begin + random.nextInt(3) + 3; List<BigDecimal> resultList = new ArrayList<BigDecimal>(); BigDecimal aggregatedReturned = sum.setsAggregated(plate.dataSet(), weightsIndices, begin, end - begin, mc); 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.getSumsq(); BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble, mc); BigDecimal[] corrected = correctRoundingErrors(aggregatedResult, aggregatedReturned); assertEquals(corrected[0], corrected[1]); } }