List of usage examples for org.apache.commons.math3.stat.descriptive DescriptiveStatistics getVariance
public double getVariance()
From source file:com.github.jessemull.microflex.stat.statdouble.SampleVarianceDoubleTest.java
/** * Tests the aggregated plate statistics method using the values between the indices of * the collection./*from ww w .j av a 2 s . co m*/ */ @Test public void testAggregatedSetCollectionIndices() { int size = arrayIndices[0].first().size(); int begin = random.nextInt(size - 5); int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1); List<WellSetDouble> collection = new ArrayList<WellSetDouble>(); for (PlateDouble plate : arrayIndices) { collection.add(plate.dataSet()); } Map<WellSetDouble, Double> aggregatedReturnedMap = variance.setsAggregated(collection, begin, end - begin); Map<WellSetDouble, Double> aggregatedResultMap = new TreeMap<WellSetDouble, Double>(); for (WellSetDouble set : collection) { List<Double> resultList = new ArrayList<Double>(); for (WellDouble well : set) { resultList.addAll(well.data().subList(begin, end)); } 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 aggregatedResult = statAggregated.getVariance(); aggregatedResultMap.put(set, aggregatedResult); } for (WellSetDouble set : collection) { double result = Precision.round(aggregatedResultMap.get(set), precision); double returned = Precision.round(aggregatedReturnedMap.get(set), precision); assertTrue(result == returned); } }
From source file:com.github.jessemull.microflex.stat.statinteger.SampleVarianceIntegerTest.java
/** * Tests the aggregated plate statistics method using the values between the indices. */// w w w .j a va 2s. c om @Test public void testAggregatedPlateIndices() { for (PlateInteger plate : arrayIndices) { int size = arrayIndices[0].first().size(); int begin = random.nextInt(size - 5); int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1); List<Double> resultList = new ArrayList<Double>(); double aggregatedReturned = Precision.round(variance.platesAggregated(plate, begin, end - begin), precision); for (WellInteger well : plate) { resultList.addAll(well.toDouble().subList(begin, end)); } 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 aggregatedResult = Precision.round(statAggregated.getVariance(), precision); assertTrue(aggregatedResult == aggregatedReturned); } }
From source file:com.github.jessemull.microflex.stat.statinteger.SampleVarianceIntegerTest.java
/** * Tests the aggregated plate statistics method using the values between the indices. *//*from w w w . ja va 2s.c o m*/ @Test public void testAggregatedSetIndices() { for (PlateInteger plate : arrayIndices) { int size = arrayIndices[0].first().size(); int begin = random.nextInt(size - 5); int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1); List<Double> resultList = new ArrayList<Double>(); double aggregatedReturned = Precision .round(variance.setsAggregated(plate.dataSet(), begin, end - begin), precision); for (WellInteger well : plate) { resultList.addAll(well.toDouble().subList(begin, end)); } 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.statinteger.SampleVarianceIntegerTest.java
/** * Tests the aggregated plate statistics method using the values between the indices of * the array./* ww w . j a v a 2s . c o m*/ */ @Test public void testAggregatedSetArrayIndices() { int size = arrayIndices[0].first().size(); int begin = random.nextInt(size - 5); int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1); WellSetInteger[] setArrayIndices = new WellSetInteger[arrayIndices.length]; for (int i = 0; i < setArrayIndices.length; i++) { setArrayIndices[i] = arrayIndices[i].dataSet(); } Map<WellSetInteger, Double> aggregatedReturnedMap = variance.setsAggregated(setArrayIndices, begin, end - begin); Map<WellSetInteger, Double> aggregatedResultMap = new TreeMap<WellSetInteger, Double>(); for (WellSetInteger set : setArrayIndices) { List<Double> resultList = new ArrayList<Double>(); for (WellInteger well : set) { resultList.addAll(well.toDouble().subList(begin, end)); } 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 aggregatedResult = statAggregated.getVariance(); aggregatedResultMap.put(set, aggregatedResult); } for (WellSetInteger plate : setArrayIndices) { double result = Precision.round(aggregatedResultMap.get(plate), precision); double returned = Precision.round(aggregatedReturnedMap.get(plate), precision); assertTrue(result == returned); } }
From source file:com.github.jessemull.microflex.stat.statdouble.SampleVarianceDoubleTest.java
/** * Tests the aggregated plate statistics method using the values between the indices. */// www .j ava2s . c o m @Test public void testAggregatedPlateIndices() { for (PlateDouble plate : arrayIndices) { int size = arrayIndices[0].first().size(); int begin = random.nextInt(size - 5); int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1); List<Double> resultList = new ArrayList<Double>(); double aggregatedReturned = Precision.round(variance.platesAggregated(plate, begin, end - begin), precision); for (WellDouble well : plate) { resultList.addAll(well.data().subList(begin, end)); } 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 aggregatedResult = Precision.round(statAggregated.getVariance(), precision); assertTrue(aggregatedResult == aggregatedReturned); } }
From source file:com.github.jessemull.microflex.stat.statdouble.SampleVarianceDoubleTest.java
/** * Tests the aggregated plate statistics method using the values between the indices. *///from w w w. ja va 2s . c o m @Test public void testAggregatedSetIndices() { for (PlateDouble plate : arrayIndices) { int size = arrayIndices[0].first().size(); int begin = random.nextInt(size - 5); int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1); List<Double> resultList = new ArrayList<Double>(); double aggregatedReturned = Precision .round(variance.setsAggregated(plate.dataSet(), begin, end - begin), precision); for (WellDouble well : plate) { resultList.addAll(well.data().subList(begin, end)); } 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.SampleVarianceDoubleTest.java
/** * Tests the aggregated plate statistics method using the values between the indices of * the array.//w ww .j a v a 2 s. co m */ @Test public void testAggregatedSetArrayIndices() { int size = arrayIndices[0].first().size(); int begin = random.nextInt(size - 5); int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1); WellSetDouble[] setArrayIndices = new WellSetDouble[arrayIndices.length]; for (int i = 0; i < setArrayIndices.length; i++) { setArrayIndices[i] = arrayIndices[i].dataSet(); } Map<WellSetDouble, Double> aggregatedReturnedMap = variance.setsAggregated(setArrayIndices, begin, end - begin); Map<WellSetDouble, Double> aggregatedResultMap = new TreeMap<WellSetDouble, Double>(); for (WellSetDouble set : setArrayIndices) { List<Double> resultList = new ArrayList<Double>(); for (WellDouble well : set) { resultList.addAll(well.data().subList(begin, end)); } 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 aggregatedResult = statAggregated.getVariance(); aggregatedResultMap.put(set, aggregatedResult); } for (WellSetDouble plate : setArrayIndices) { double result = Precision.round(aggregatedResultMap.get(plate), precision); double returned = Precision.round(aggregatedReturnedMap.get(plate), precision); assertTrue(result == returned); } }
From source file:com.github.jessemull.microflexdouble.stat.SampleVarianceTest.java
/** * Tests well calculation using indices. *//* www.jav a2s .co m*/ @Test public void testWellIndices() { for (Plate plate : arrayIndices) { for (Well well : plate) { double[] input = new double[well.size()]; int index = 0; for (double bd : well) { input[index++] = bd; ; } int size = arrayIndices[0].first().size(); int begin = random.nextInt(size - 5); int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1); DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end)); double result = Precision.round(stat.getVariance(), precision); double returned = Precision.round(variance.well(well, begin, end - begin), precision); assertTrue(result == returned); } } }
From source file:com.github.jessemull.microflex.stat.statinteger.SampleVarianceIntegerTest.java
/** * Tests well calculation using indices. *///from ww w . j ava 2 s.c o m @Test public void testWellIndices() { for (PlateInteger plate : arrayIndices) { for (WellInteger well : plate) { double[] input = new double[well.size()]; int index = 0; for (double bd : well) { input[index++] = bd; ; } int size = arrayIndices[0].first().size(); int begin = random.nextInt(size - 5); int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1); DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end)); double result = Precision.round(stat.getVariance(), precision); double returned = Precision.round(variance.well(well, begin, end - begin), precision); assertTrue(result == returned); } } }
From source file:com.github.jessemull.microflex.stat.statdouble.SampleVarianceDoubleTest.java
/** * Tests well calculation using indices. *//*from w ww . ja v a2s . c o m*/ @Test public void testWellIndices() { for (PlateDouble plate : arrayIndices) { for (WellDouble well : plate) { double[] input = new double[well.size()]; int index = 0; for (double bd : well) { input[index++] = bd; ; } int size = arrayIndices[0].first().size(); int begin = random.nextInt(size - 5); int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1); DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end)); double result = Precision.round(stat.getVariance(), precision); double returned = Precision.round(variance.well(well, begin, end - begin), precision); assertTrue(result == returned); } } }