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.microflex.stat.statbigdecimal.PopulationVarianceBigDecimalWeightsTest.java
/** * Tests the plate statistics method using the values between the indices. *//*from w w w . j a v a 2 s .co m*/ @Test public void testPlateIndices() { for (PlateBigDecimal plate : arrayIndices) { int begin = random.nextInt(plate.first().size() - 4); int end = begin + random.nextInt(3) + 3; Map<WellBigDecimal, BigDecimal> resultMap = new TreeMap<WellBigDecimal, BigDecimal>(); Map<WellBigDecimal, BigDecimal> returnedMap = variance.plate(plate, ArrayUtils.subarray(weightsIndices, begin, end), begin, end - begin, mc); for (WellBigDecimal 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.getPopulationVariance(); BigDecimal result = new BigDecimal(resultDouble, mc); resultMap.put(well, result); } for (WellBigDecimal 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.NTest.java
/** * Tests the aggregated plate statistics method using an array. *//* w w w . j a v a2 s . c om*/ @Test public void testAggregatedPlateArray() { Map<Plate, Integer> aggregatedReturnedMap = n.platesAggregated(array); Map<Plate, Integer> aggregatedResultMap = new TreeMap<Plate, Integer>(); for (Plate plate : array) { List<Double> resultList = new ArrayList<Double>(); for (Well well : plate) { for (double db : well) { resultList.add(db); } } 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 = statAggregated.getN(); aggregatedResultMap.put(plate, (int) resultAggregated); } for (Plate plate : array) { int result = aggregatedResultMap.get(plate); int returned = aggregatedReturnedMap.get(plate); assertEquals(result, returned); } }
From source file:com.github.jessemull.microflex.stat.statinteger.SampleVarianceIntegerTest.java
/** * Tests the aggregated plate statistics method. *///from w ww. j ava2 s . c o m @Test public void testAggregatedPlate() { for (PlateInteger plate : array) { List<Double> resultList = new ArrayList<Double>(); double aggregatedReturned = Precision.round(variance.platesAggregated(plate), precision); for (WellInteger 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.getVariance(), precision); assertTrue(resultAggregated == aggregatedReturned); } }
From source file:com.github.jessemull.microflex.stat.statdouble.PopulationVarianceDoubleTest.java
/** * Tests the aggregated plate statistics method. *//*from w w w . j av a 2 s . c om*/ @Test public void testAggregatedPlate() { for (PlateDouble plate : array) { List<Double> resultList = new ArrayList<Double>(); double aggregatedReturned = Precision.round(variance.platesAggregated(plate), precision); for (WellDouble 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.getPopulationVariance(), precision); assertTrue(resultAggregated == aggregatedReturned); } }
From source file:com.github.jessemull.microflexdouble.stat.PercentileTest.java
/** * Tests the aggregated plate statistics method. *///from w w w.j a v a 2 s . c o m @Test public void testAggregatedPlate() { for (Plate plate : array) { int inputPercentile = 1 + random.nextInt(100); List<Double> resultList = new ArrayList<Double>(); double aggregatedReturned = Precision.round(percentile.platesAggregated(plate, inputPercentile), 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).doubleValue(); } DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated); double resultAggregated = Precision.round(statAggregated.getPercentile(inputPercentile), precision); assertTrue(resultAggregated == aggregatedReturned); } }
From source file:com.github.jessemull.microflexinteger.stat.PercentileTest.java
/** * Tests the aggregated plate statistics method. *//* ww w . jav a 2s .co m*/ @Test public void testAggregatedPlate() { for (Plate plate : array) { int inputPercentile = 1 + random.nextInt(100); List<Double> resultList = new ArrayList<Double>(); double aggregatedReturned = Precision.round(percentile.platesAggregated(plate, inputPercentile), 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).doubleValue(); } DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated); double resultAggregated = Precision.round(statAggregated.getPercentile(inputPercentile), precision); assertTrue(resultAggregated == aggregatedReturned); } }
From source file:com.github.jessemull.microflex.stat.statdouble.SampleStandardDeviationDoubleTest.java
/** * Tests the aggregated plate statistics method. */// ww w . j a va 2 s . c o m @Test public void testAggregatedPlate() { for (PlateDouble plate : array) { List<Double> resultList = new ArrayList<Double>(); double aggregatedReturned = Precision.round(deviation.platesAggregated(plate), precision); for (WellDouble 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.getStandardDeviation(), precision); assertTrue(resultAggregated == aggregatedReturned); } }
From source file:com.github.jessemull.microflex.stat.statinteger.PopulationVarianceIntegerTest.java
/** * Tests the aggregated plate statistics method. */// w w w . java 2s . c om @Test public void testAggregatedPlate() { for (PlateInteger plate : array) { List<Double> resultList = new ArrayList<Double>(); double aggregatedReturned = Precision.round(variance.platesAggregated(plate), precision); for (WellInteger 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.getPopulationVariance(), precision); assertTrue(resultAggregated == aggregatedReturned); } }
From source file:com.github.jessemull.microflex.stat.statinteger.StandardDeviationIntegerTest.java
/** * Tests the aggregated plate statistics method. */// w w w.j a va 2 s . c o m @Test public void testAggregatedPlate() { for (PlateInteger plate : array) { List<Double> resultList = new ArrayList<Double>(); double aggregatedReturned = Precision.round(deviation.platesAggregated(plate), precision); for (WellInteger 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.getStandardDeviation(), precision); assertTrue(resultAggregated == aggregatedReturned); } }
From source file:com.github.jessemull.microflexdouble.stat.SumWeightsTest.java
/** * Tests the aggregated plate statistics method. *///from w w w. j a va 2 s. com @Test public void testAggregatedPlate() { for (Plate plate : array) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); double aggregatedReturned = Precision.round(sum.platesAggregated(plate, weights), precision); 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 resultAggregated = Precision.round(statAggregated.getSum(), precision); assertTrue(resultAggregated == aggregatedReturned); } }