List of usage examples for org.apache.commons.math3.stat.descriptive DescriptiveStatistics DescriptiveStatistics
public DescriptiveStatistics(DescriptiveStatistics original) throws NullArgumentException
From source file:com.github.jessemull.microflexbigdecimal.stat.SampleVarianceWeightsTest.java
/** * Tests the plate statistics method using the values between the indices. *//*from ww w . j a va 2 s.co 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 = variance.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 (BigDecimal bd : well) { input[index] = bd.doubleValue() * weightsIndices[index]; index++; } DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end)); double resultDouble = stat.getVariance(); 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.statbiginteger.PopulationVarianceBigIntegerTest.java
/** * Tests the plate statistics method using the values between the indices. *//* w w w . ja v a 2s. c o m*/ @Test public void testPlateIndices() { for (PlateBigInteger plate : arrayIndices) { int size = arrayIndices[0].first().size(); int begin = random.nextInt(size - 5); int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1); Map<WellBigInteger, BigDecimal> resultMap = new TreeMap<WellBigInteger, BigDecimal>(); Map<WellBigInteger, BigDecimal> returnedMap = variance.plate(plate, 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(); } double[] inputArray = ArrayUtils.subarray(input, begin, end); DescriptiveStatistics stat = new DescriptiveStatistics(inputArray); double resultDouble = stat.getVariance(); resultDouble *= inputArray.length - 1; resultDouble /= inputArray.length; BigDecimal result = new BigDecimal(resultDouble); 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.microflexdouble.stat.MaxTest.java
/** * Tests the aggregated plate statistics method. */// w w w . j a v a2 s. c om @Test public void testAggregatedPlate() { for (Plate plate : array) { List<Double> resultList = new ArrayList<Double>(); double aggregatedReturned = Precision.round(max.platesAggregated(plate), precision); 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); } DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated); double resultAggregated = Precision.round(statAggregated.getMax(), precision); assertTrue(resultAggregated == aggregatedReturned); } }
From source file:com.github.jessemull.microflexdouble.stat.MinTest.java
/** * Tests the aggregated plate statistics method. *//* w ww . j a v a 2 s .co m*/ @Test public void testAggregatedPlate() { for (Plate plate : array) { List<Double> resultList = new ArrayList<Double>(); double aggregatedReturned = Precision.round(min.platesAggregated(plate), precision); 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); } DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated); double resultAggregated = Precision.round(statAggregated.getMin(), precision); assertTrue(resultAggregated == aggregatedReturned); } }
From source file:com.github.jessemull.microflexdouble.stat.SumTest.java
/** * Tests the aggregated plate statistics method. *//*from w ww . ja va2s .co m*/ @Test public void testAggregatedPlate() { for (Plate plate : array) { List<Double> resultList = new ArrayList<Double>(); double aggregatedReturned = Precision.round(sum.platesAggregated(plate), precision); 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); } DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated); double resultAggregated = Precision.round(statAggregated.getSum(), precision); assertTrue(resultAggregated == aggregatedReturned); } }
From source file:com.github.jessemull.microflexinteger.stat.MaxTest.java
/** * Tests the aggregated plate statistics method. *///from w w w. j a va 2 s . c o m @Test public void testAggregatedPlate() { for (Plate plate : array) { List<Double> resultList = new ArrayList<Double>(); double aggregatedReturned = Precision.round(max.platesAggregated(plate), precision); for (Well well : plate) { resultList.addAll(well.toDouble()); } double[] inputAggregated = new double[resultList.size()]; for (int i = 0; i < resultList.size(); i++) { inputAggregated[i] = resultList.get(i); } DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated); double resultAggregated = Precision.round(statAggregated.getMax(), precision); assertTrue(resultAggregated == aggregatedReturned); } }
From source file:com.github.jessemull.microflexinteger.stat.MinTest.java
/** * Tests the aggregated plate statistics method. *///from ww w .j a v a 2 s . co m @Test public void testAggregatedPlate() { for (Plate plate : array) { List<Double> resultList = new ArrayList<Double>(); double aggregatedReturned = Precision.round(min.platesAggregated(plate), precision); for (Well well : plate) { resultList.addAll(well.toDouble()); } double[] inputAggregated = new double[resultList.size()]; for (int i = 0; i < resultList.size(); i++) { inputAggregated[i] = resultList.get(i); } DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated); double resultAggregated = Precision.round(statAggregated.getMin(), precision); assertTrue(resultAggregated == aggregatedReturned); } }
From source file:com.github.jessemull.microflexinteger.stat.SumTest.java
/** * Tests the aggregated plate statistics method. *///from w ww .ja va 2 s.c om @Test public void testAggregatedPlate() { for (Plate plate : array) { List<Double> resultList = new ArrayList<Double>(); double aggregatedReturned = Precision.round(sum.platesAggregated(plate), precision); for (Well well : plate) { resultList.addAll(well.toDouble()); } double[] inputAggregated = new double[resultList.size()]; for (int i = 0; i < resultList.size(); i++) { inputAggregated[i] = resultList.get(i); } DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated); double resultAggregated = Precision.round(statAggregated.getSum(), precision); assertTrue(resultAggregated == aggregatedReturned); } }
From source file:com.github.jessemull.microflexdouble.stat.MeanTest.java
/** * Tests the aggregated plate statistics method. */// w ww .j a v a 2 s .c o m @Test public void testAggregatedPlate() { for (Plate plate : array) { List<Double> resultList = new ArrayList<Double>(); double aggregatedReturned = Precision.round(mean.platesAggregated(plate), precision); 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); } DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated); double resultAggregated = Precision.round(statAggregated.getMean(), precision); assertTrue(resultAggregated == aggregatedReturned); } }
From source file:com.github.jessemull.microflexinteger.stat.MeanTest.java
/** * Tests the aggregated plate statistics method. *//*from w ww . j a v a 2 s. co m*/ @Test public void testAggregatedPlate() { for (Plate plate : array) { List<Double> resultList = new ArrayList<Double>(); double aggregatedReturned = Precision.round(mean.platesAggregated(plate), precision); for (Well well : plate) { resultList.addAll(well.toDouble()); } double[] inputAggregated = new double[resultList.size()]; for (int i = 0; i < resultList.size(); i++) { inputAggregated[i] = resultList.get(i); } DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated); double resultAggregated = Precision.round(statAggregated.getMean(), precision); assertTrue(resultAggregated == aggregatedReturned); } }