List of usage examples for org.apache.commons.math3.stat.descriptive DescriptiveStatistics getPopulationVariance
public double getPopulationVariance()
From source file:com.github.jessemull.microflex.stat.statdouble.PopulationVarianceDoubleWeightsTest.java
/** * Tests the aggregated plate statistics method using a collection. *//*from w w w . j a v a 2s .co m*/ @Test public void testAggregatedSetCollection() { List<WellSetDouble> collection = new ArrayList<WellSetDouble>(); for (PlateDouble plate : array) { collection.add(plate.dataSet()); } Map<WellSetDouble, Double> aggregatedReturnedMap = variance.setsAggregated(collection, weights); Map<WellSetDouble, Double> aggregatedResultMap = new TreeMap<WellSetDouble, Double>(); for (WellSetDouble set : collection) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); for (WellDouble well : set) { 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 aggregatedResult = statAggregated.getPopulationVariance(); 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.PopulationVarianceIntegerWeightsTest.java
/** * Tests the aggregated plate statistics method. *//* w w w . j a va2 s .co m*/ @Test public void testAggregatedPlate() { for (PlateInteger plate : array) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); double aggregatedReturned = Precision.round(variance.platesAggregated(plate, weights), precision); for (WellInteger 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.getPopulationVariance(), precision); assertTrue(resultAggregated == aggregatedReturned); } }
From source file:com.github.jessemull.microflex.stat.statinteger.PopulationVarianceIntegerWeightsTest.java
/** * Tests the aggregated plate statistics method using the values between the indices of * the collection.// w ww .ja va 2s . c o m */ @Test public void testAggregatedPlateCollectionIndices() { int begin = random.nextInt(arrayIndices[0].first().size() - 4); int end = begin + random.nextInt(3) + 3; List<PlateInteger> collection = Arrays.asList(arrayIndices); Map<PlateInteger, Double> aggregatedReturnedMap = variance.platesAggregated(collection, weightsIndices, begin, end - begin); Map<PlateInteger, Double> aggregatedResultMap = new TreeMap<PlateInteger, Double>(); for (PlateInteger plate : collection) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); for (WellInteger 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 aggregatedResult = statAggregated.getPopulationVariance(); aggregatedResultMap.put(plate, aggregatedResult); } for (PlateInteger plate : collection) { 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.statinteger.PopulationVarianceIntegerWeightsTest.java
/** * Tests the aggregated plate statistics method using a collection. *///from ww w. j av a 2s.c o m @Test public void testAggregatedSetCollection() { List<WellSetInteger> collection = new ArrayList<WellSetInteger>(); for (PlateInteger plate : array) { collection.add(plate.dataSet()); } Map<WellSetInteger, Double> aggregatedReturnedMap = variance.setsAggregated(collection, weights); Map<WellSetInteger, Double> aggregatedResultMap = new TreeMap<WellSetInteger, Double>(); for (WellSetInteger set : collection) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); for (WellInteger well : set) { 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 aggregatedResult = statAggregated.getPopulationVariance(); aggregatedResultMap.put(set, aggregatedResult); } for (WellSetInteger 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.microflexdouble.stat.PopulationVarianceWeightsTest.java
/** * Tests the aggregated plate statistics method. *//*from w w w . ja v a2 s.co m*/ @Test public void testAggregatedSet() { for (Plate plate : array) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); double aggregatedReturned = Precision.round(variance.setsAggregated(plate.dataSet(), 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 aggregatedResult = Precision.round(statAggregated.getPopulationVariance(), precision); assertTrue(aggregatedResult == aggregatedReturned); } }
From source file:com.github.jessemull.microflexdouble.stat.PopulationVarianceWeightsTest.java
/** * Tests the aggregated plate statistics method using an array. *//* w w w. j av a2 s .c o m*/ @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, Double> aggregatedReturnedMap = variance.setsAggregated(setArray, weights); Map<WellSet, Double> aggregatedResultMap = new TreeMap<WellSet, Double>(); for (WellSet set : setArray) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); for (Well well : set) { 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 aggregatedResult = statAggregated.getPopulationVariance(); aggregatedResultMap.put(set, aggregatedResult); } for (WellSet set : setArray) { 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.statdouble.PopulationVarianceDoubleWeightsTest.java
/** * Tests the aggregated plate statistics method. *//* w w w. j a v a 2s . c om*/ @Test public void testAggregatedSet() { for (PlateDouble plate : array) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); double aggregatedReturned = Precision.round(variance.setsAggregated(plate.dataSet(), weights), precision); for (WellDouble 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 aggregatedResult = Precision.round(statAggregated.getPopulationVariance(), precision); assertTrue(aggregatedResult == aggregatedReturned); } }
From source file:com.github.jessemull.microflex.stat.statdouble.PopulationVarianceDoubleWeightsTest.java
/** * Tests the aggregated plate statistics method using an array. *///ww w.j a va 2s .c o m @Test public void testAggregatedSetArray() { WellSetDouble[] setArray = new WellSetDouble[array.length]; for (int i = 0; i < setArray.length; i++) { setArray[i] = array[i].dataSet(); } Map<WellSetDouble, Double> aggregatedReturnedMap = variance.setsAggregated(setArray, weights); Map<WellSetDouble, Double> aggregatedResultMap = new TreeMap<WellSetDouble, Double>(); for (WellSetDouble set : setArray) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); for (WellDouble well : set) { 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 aggregatedResult = statAggregated.getPopulationVariance(); aggregatedResultMap.put(set, aggregatedResult); } for (WellSetDouble set : setArray) { 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.PopulationVarianceIntegerWeightsTest.java
/** * Tests the aggregated plate statistics method. */// w w w. jav a2 s . c o m @Test public void testAggregatedSet() { for (PlateInteger plate : array) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); double aggregatedReturned = Precision.round(variance.setsAggregated(plate.dataSet(), weights), precision); for (WellInteger 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 aggregatedResult = Precision.round(statAggregated.getPopulationVariance(), precision); assertTrue(aggregatedResult == aggregatedReturned); } }
From source file:com.github.jessemull.microflex.stat.statinteger.PopulationVarianceIntegerWeightsTest.java
/** * Tests the aggregated plate statistics method using an array. */// ww w.j a v a 2 s . co m @Test public void testAggregatedSetArray() { WellSetInteger[] setArray = new WellSetInteger[array.length]; for (int i = 0; i < setArray.length; i++) { setArray[i] = array[i].dataSet(); } Map<WellSetInteger, Double> aggregatedReturnedMap = variance.setsAggregated(setArray, weights); Map<WellSetInteger, Double> aggregatedResultMap = new TreeMap<WellSetInteger, Double>(); for (WellSetInteger set : setArray) { List<BigDecimal> resultList = new ArrayList<BigDecimal>(); for (WellInteger well : set) { 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 aggregatedResult = statAggregated.getPopulationVariance(); aggregatedResultMap.put(set, aggregatedResult); } for (WellSetInteger set : setArray) { double result = Precision.round(aggregatedResultMap.get(set), precision); double returned = Precision.round(aggregatedReturnedMap.get(set), precision); assertTrue(result == returned); } }