List of usage examples for org.apache.commons.math3.stat.descriptive DescriptiveStatistics getVariance
public double getVariance()
From source file:com.github.jessemull.microflexbiginteger.stat.PopulationVarianceTest.java
/** * Tests the aggregated plate statistics method using an array. *//*from w ww . j a v a 2 s.com*/ @Test public void testAggregatedSetArray() { WellSet[] setArray = new WellSet[array.length]; for (int i = 0; i < setArray.length; i++) { setArray[i] = array[i].dataSet(); } Map<WellSet, BigDecimal> aggregatedReturnedMap = variance.setsAggregated(setArray, mc); Map<WellSet, BigDecimal> aggregatedResultMap = new TreeMap<WellSet, BigDecimal>(); for (WellSet set : setArray) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); for (Well well : set) { resultList.addAll(well.toBigDecimal()); } 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.getVariance(); resultAggregatedDouble *= resultList.size() - 1; resultAggregatedDouble /= resultList.size(); BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble); aggregatedResultMap.put(set, aggregatedResult); } for (WellSet set : setArray) { BigDecimal result = aggregatedResultMap.get(set); BigDecimal returned = aggregatedReturnedMap.get(set); BigDecimal[] corrected = correctRoundingErrors(result, returned); assertEquals(corrected[0], corrected[1]); } }
From source file:com.github.jessemull.microflex.stat.statbiginteger.PopulationVarianceBigIntegerTest.java
/** * Tests the aggregated plate statistics method using an array. *//*w w w .j a v a2 s . co m*/ @Test public void testAggregatedSetArray() { WellSetBigInteger[] setArray = new WellSetBigInteger[array.length]; for (int i = 0; i < setArray.length; i++) { setArray[i] = array[i].dataSet(); } Map<WellSetBigInteger, BigDecimal> aggregatedReturnedMap = variance.setsAggregated(setArray, mc); Map<WellSetBigInteger, BigDecimal> aggregatedResultMap = new TreeMap<WellSetBigInteger, BigDecimal>(); for (WellSetBigInteger set : setArray) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); for (WellBigInteger well : set) { resultList.addAll(well.toBigDecimal()); } 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.getVariance(); resultAggregatedDouble *= resultList.size() - 1; resultAggregatedDouble /= resultList.size(); BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble); aggregatedResultMap.put(set, aggregatedResult); } for (WellSetBigInteger set : setArray) { BigDecimal result = aggregatedResultMap.get(set); BigDecimal returned = aggregatedReturnedMap.get(set); BigDecimal[] corrected = correctRoundingErrors(result, returned); assertEquals(corrected[0], corrected[1]); } }
From source file:com.github.jessemull.microflex.stat.statbigdecimal.PopulationVarianceBigDecimalTest.java
/** * Tests the aggregated plate statistics method using the values between the indices of * the collection.//from w w w.j a v a 2 s. c om */ @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<WellSetBigDecimal> collection = new ArrayList<WellSetBigDecimal>(); for (PlateBigDecimal plate : arrayIndices) { collection.add(plate.dataSet()); } Map<WellSetBigDecimal, BigDecimal> aggregatedReturnedMap = variance.setsAggregated(collection, begin, end - begin, mc); Map<WellSetBigDecimal, BigDecimal> aggregatedResultMap = new TreeMap<WellSetBigDecimal, BigDecimal>(); for (WellSetBigDecimal set : collection) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); for (WellBigDecimal 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).doubleValue(); } DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated); double resultAggregatedDouble = statAggregated.getVariance(); resultAggregatedDouble *= resultList.size() - 1; resultAggregatedDouble /= resultList.size(); BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble); aggregatedResultMap.put(set, aggregatedResult); } for (WellSetBigDecimal set : collection) { BigDecimal result = aggregatedResultMap.get(set); BigDecimal returned = aggregatedReturnedMap.get(set); BigDecimal[] corrected = correctRoundingErrors(result, returned); assertEquals(corrected[0], corrected[1]); } }
From source file:com.github.jessemull.microflexbigdecimal.stat.PopulationVarianceTest.java
/** * Tests the aggregated plate statistics method using the values between the indices of * the collection.//www .j a v a 2s.c o 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<WellSet> collection = new ArrayList<WellSet>(); for (Plate plate : arrayIndices) { collection.add(plate.dataSet()); } Map<WellSet, BigDecimal> aggregatedReturnedMap = variance.setsAggregated(collection, begin, end - begin, mc); Map<WellSet, BigDecimal> aggregatedResultMap = new TreeMap<WellSet, BigDecimal>(); for (WellSet set : collection) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); for (Well 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).doubleValue(); } DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated); double resultAggregatedDouble = statAggregated.getVariance(); resultAggregatedDouble *= resultList.size() - 1; resultAggregatedDouble /= resultList.size(); BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble); aggregatedResultMap.put(set, aggregatedResult); } for (WellSet set : collection) { BigDecimal result = aggregatedResultMap.get(set); BigDecimal returned = aggregatedReturnedMap.get(set); BigDecimal[] corrected = correctRoundingErrors(result, returned); assertEquals(corrected[0], corrected[1]); } }
From source file:com.github.jessemull.microflex.stat.statbigdecimal.PopulationVarianceBigDecimalTest.java
/** * Tests the aggregated plate statistics method using the values between the indices of * the array.// w ww .j a va 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); WellSetBigDecimal[] setArrayIndices = new WellSetBigDecimal[arrayIndices.length]; for (int i = 0; i < setArrayIndices.length; i++) { setArrayIndices[i] = arrayIndices[i].dataSet(); } Map<WellSetBigDecimal, BigDecimal> aggregatedReturnedMap = variance.setsAggregated(setArrayIndices, begin, end - begin, mc); Map<WellSetBigDecimal, BigDecimal> aggregatedResultMap = new TreeMap<WellSetBigDecimal, BigDecimal>(); for (WellSetBigDecimal set : setArrayIndices) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); for (WellBigDecimal 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).doubleValue(); } DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated); double resultAggregatedDouble = statAggregated.getVariance(); resultAggregatedDouble *= resultList.size() - 1; resultAggregatedDouble /= resultList.size(); BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble); aggregatedResultMap.put(set, aggregatedResult); } for (WellSetBigDecimal plate : setArrayIndices) { 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.PopulationVarianceTest.java
/** * Tests the aggregated plate statistics method using the values between the indices of * the array./*w w w . java 2 s . 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); WellSet[] setArrayIndices = new WellSet[arrayIndices.length]; for (int i = 0; i < setArrayIndices.length; i++) { setArrayIndices[i] = arrayIndices[i].dataSet(); } Map<WellSet, BigDecimal> aggregatedReturnedMap = variance.setsAggregated(setArrayIndices, begin, end - begin, mc); Map<WellSet, BigDecimal> aggregatedResultMap = new TreeMap<WellSet, BigDecimal>(); for (WellSet set : setArrayIndices) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); for (Well 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).doubleValue(); } DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated); double resultAggregatedDouble = statAggregated.getVariance(); resultAggregatedDouble *= resultList.size() - 1; resultAggregatedDouble /= resultList.size(); BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble); aggregatedResultMap.put(set, aggregatedResult); } for (WellSet plate : setArrayIndices) { 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.PopulationVarianceTest.java
/** * Tests the aggregated plate statistics method using the values between the indices of * the collection./*from ww w . ja v 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<WellSet> collection = new ArrayList<WellSet>(); for (Plate plate : arrayIndices) { collection.add(plate.dataSet()); } Map<WellSet, BigDecimal> aggregatedReturnedMap = variance.setsAggregated(collection, begin, end - begin, mc); Map<WellSet, BigDecimal> aggregatedResultMap = new TreeMap<WellSet, BigDecimal>(); for (WellSet set : collection) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); for (Well well : set) { resultList.addAll(well.toBigDecimal().subList(begin, end)); } 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.getVariance(); resultAggregatedDouble *= resultList.size() - 1; resultAggregatedDouble /= resultList.size(); BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble); aggregatedResultMap.put(set, aggregatedResult); } for (WellSet set : collection) { BigDecimal result = aggregatedResultMap.get(set); BigDecimal returned = aggregatedReturnedMap.get(set); BigDecimal[] corrected = correctRoundingErrors(result, returned); assertEquals(corrected[0], corrected[1]); } }
From source file:com.github.jessemull.microflex.stat.statbiginteger.PopulationVarianceBigIntegerTest.java
/** * Tests the aggregated plate statistics method using the values between the indices of * the collection./* w w w . ja v a2s . c o 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<WellSetBigInteger> collection = new ArrayList<WellSetBigInteger>(); for (PlateBigInteger plate : arrayIndices) { collection.add(plate.dataSet()); } Map<WellSetBigInteger, BigDecimal> aggregatedReturnedMap = variance.setsAggregated(collection, begin, end - begin, mc); Map<WellSetBigInteger, BigDecimal> aggregatedResultMap = new TreeMap<WellSetBigInteger, BigDecimal>(); for (WellSetBigInteger set : collection) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); for (WellBigInteger well : set) { resultList.addAll(well.toBigDecimal().subList(begin, end)); } 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.getVariance(); resultAggregatedDouble *= resultList.size() - 1; resultAggregatedDouble /= resultList.size(); BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble); aggregatedResultMap.put(set, aggregatedResult); } for (WellSetBigInteger set : collection) { BigDecimal result = aggregatedResultMap.get(set); BigDecimal returned = aggregatedReturnedMap.get(set); BigDecimal[] corrected = correctRoundingErrors(result, returned); assertEquals(corrected[0], corrected[1]); } }
From source file:com.github.jessemull.microflexbiginteger.stat.PopulationVarianceTest.java
/** * Tests the aggregated plate statistics method using the values between the indices of * the array./*from ww w . jav 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); WellSet[] setArrayIndices = new WellSet[arrayIndices.length]; for (int i = 0; i < setArrayIndices.length; i++) { setArrayIndices[i] = arrayIndices[i].dataSet(); } Map<WellSet, BigDecimal> aggregatedReturnedMap = variance.setsAggregated(setArrayIndices, begin, end - begin, mc); Map<WellSet, BigDecimal> aggregatedResultMap = new TreeMap<WellSet, BigDecimal>(); for (WellSet set : setArrayIndices) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); for (Well well : set) { resultList.addAll(well.toBigDecimal().subList(begin, end)); } 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.getVariance(); resultAggregatedDouble *= resultList.size() - 1; resultAggregatedDouble /= resultList.size(); BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble); aggregatedResultMap.put(set, aggregatedResult); } for (WellSet plate : setArrayIndices) { 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.PopulationVarianceBigIntegerTest.java
/** * Tests the aggregated plate statistics method using the values between the indices of * the array.//w w w.j a v a2 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); WellSetBigInteger[] setArrayIndices = new WellSetBigInteger[arrayIndices.length]; for (int i = 0; i < setArrayIndices.length; i++) { setArrayIndices[i] = arrayIndices[i].dataSet(); } Map<WellSetBigInteger, BigDecimal> aggregatedReturnedMap = variance.setsAggregated(setArrayIndices, begin, end - begin, mc); Map<WellSetBigInteger, BigDecimal> aggregatedResultMap = new TreeMap<WellSetBigInteger, BigDecimal>(); for (WellSetBigInteger set : setArrayIndices) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); for (WellBigInteger well : set) { resultList.addAll(well.toBigDecimal().subList(begin, end)); } 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.getVariance(); resultAggregatedDouble *= resultList.size() - 1; resultAggregatedDouble /= resultList.size(); BigDecimal aggregatedResult = new BigDecimal(resultAggregatedDouble); aggregatedResultMap.put(set, aggregatedResult); } for (WellSetBigInteger plate : setArrayIndices) { BigDecimal result = aggregatedResultMap.get(plate); BigDecimal returned = aggregatedReturnedMap.get(plate); BigDecimal[] corrected = correctRoundingErrors(result, returned); assertEquals(corrected[0], corrected[1]); } }