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