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.statdouble.GeometricMeanDoubleWeightsTest.java
/** * Tests the plate statistics method using the values between the indices. *//*from ww w. j a va 2 s . 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 = mean.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.getGeometricMean(); 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.microflexbiginteger.stat.NTest.java
/** * Tests the aggregated plate statistics method using a collection. *//*from w w w . jav a 2 s . c om*/ @Test public void testAggregatedPlateCollection() { List<Plate> collection = Arrays.asList(array); Map<Plate, Integer> aggregatedReturnedMap = n.platesAggregated(collection); Map<Plate, Integer> aggregatedResultMap = new TreeMap<Plate, Integer>(); for (Plate plate : collection) { List<Double> resultList = new ArrayList<Double>(); for (Well well : plate) { for (BigInteger bi : well) { resultList.add(bi.doubleValue()); } } 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 : collection) { int result = aggregatedResultMap.get(plate); int returned = aggregatedReturnedMap.get(plate); assertEquals(result, returned); } }
From source file:com.github.jessemull.microflexbiginteger.stat.KurtosisTest.java
/** * Tests the plate statistics method using the values between the indices. *//* w w w .j av a 2 s. co m*/ @Test public void testPlateIndices() { for (Plate plate : arrayIndices) { int size = arrayIndices[0].first().size(); int begin = random.nextInt(size - 5); int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1); Map<Well, BigDecimal> resultMap = new TreeMap<Well, BigDecimal>(); Map<Well, BigDecimal> returnedMap = kurtosis.plate(plate, begin, end - begin, mc); for (Well well : plate) { double[] input = new double[well.size()]; int index = 0; for (BigInteger bi : well) { input[index++] = bi.doubleValue(); } DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end)); double resultDouble = stat.getKurtosis(); BigDecimal result = new BigDecimal(resultDouble); resultMap.put(well, result); } for (Well 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.microflexbiginteger.stat.SkewnessTest.java
/** * Tests the plate statistics method using the values between the indices. *//*from w ww . j a v a2 s . c o m*/ @Test public void testPlateIndices() { for (Plate plate : arrayIndices) { int size = arrayIndices[0].first().size(); int begin = random.nextInt(size - 5); int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1); Map<Well, BigDecimal> resultMap = new TreeMap<Well, BigDecimal>(); Map<Well, BigDecimal> returnedMap = skewness.plate(plate, begin, end - begin, mc); for (Well well : plate) { double[] input = new double[well.size()]; int index = 0; for (BigInteger bi : well) { input[index++] = bi.doubleValue(); } DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end)); double resultDouble = stat.getSkewness(); BigDecimal result = new BigDecimal(resultDouble); resultMap.put(well, result); } for (Well 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.microflex.stat.statinteger.SumOfSquaresIntegerWeightsTest.java
/** * Tests the plate statistics method using the values between the indices. */// ww w. ja v a 2s . com @Test public void testPlateIndices() { for (PlateInteger plate : arrayIndices) { int begin = random.nextInt(plate.first().size() - 4); int end = begin + random.nextInt(3) + 3; Map<WellInteger, Double> resultMap = new TreeMap<WellInteger, Double>(); Map<WellInteger, Double> returnedMap = sum.plate(plate, ArrayUtils.subarray(weightsIndices, begin, end), begin, end - begin); for (WellInteger 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.getSumsq(); resultMap.put(well, result); } for (WellInteger 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.SampleVarianceDoubleWeightsTest.java
/** * Tests the plate statistics method using the values between the indices. *//*from ww w .ja va 2s .co m*/ @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.getVariance(); 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.NDoubleTest.java
/** * Tests the aggregated plate statistics method using a collection. *///from w w w .j a va 2s . c om @Test public void testAggregatedPlateCollection() { List<PlateDouble> collection = Arrays.asList(array); Map<PlateDouble, Integer> aggregatedReturnedMap = n.platesAggregated(collection); Map<PlateDouble, Integer> aggregatedResultMap = new TreeMap<PlateDouble, Integer>(); for (PlateDouble plate : collection) { List<Double> resultList = new ArrayList<Double>(); for (WellDouble 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 (PlateDouble plate : collection) { int result = aggregatedResultMap.get(plate); int returned = aggregatedReturnedMap.get(plate); assertEquals(result, returned); } }
From source file:com.github.jessemull.microflex.stat.statinteger.GeometricMeanIntegerWeightsTest.java
/** * Tests the plate statistics method using the values between the indices. *//*from w w w . j a va2s . c o m*/ @Test public void testPlateIndices() { for (PlateInteger plate : arrayIndices) { int begin = random.nextInt(plate.first().size() - 4); int end = begin + random.nextInt(3) + 3; Map<WellInteger, Double> resultMap = new TreeMap<WellInteger, Double>(); Map<WellInteger, Double> returnedMap = mean.plate(plate, ArrayUtils.subarray(weightsIndices, begin, end), begin, end - begin); for (WellInteger 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.getGeometricMean(); resultMap.put(well, result); } for (WellInteger 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.statinteger.SampleVarianceIntegerWeightsTest.java
/** * Tests the plate statistics method using the values between the indices. *///from w w w. j a va 2 s. c o m @Test public void testPlateIndices() { for (PlateInteger plate : arrayIndices) { int begin = random.nextInt(plate.first().size() - 4); int end = begin + random.nextInt(3) + 3; Map<WellInteger, Double> resultMap = new TreeMap<WellInteger, Double>(); Map<WellInteger, Double> returnedMap = variance.plate(plate, ArrayUtils.subarray(weightsIndices, begin, end), begin, end - begin); for (WellInteger 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.getVariance(); resultMap.put(well, result); } for (WellInteger 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. */// www . ja v a 2s . c o m @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); } } }