List of usage examples for java.math BigInteger doubleValue
public double doubleValue()
From source file:com.github.jessemull.microflexbiginteger.stat.PopulationVarianceTest.java
/** * Tests set calculation using indices.//from ww w . j a v a 2 s .c om */ @Test public void testSetIndices() { 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 = variance.set(plate.dataSet(), 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(); } double[] inputArray = ArrayUtils.subarray(input, begin, end); DescriptiveStatistics stat = new DescriptiveStatistics(inputArray); double resultDouble = stat.getVariance(); resultDouble *= inputArray.length - 1; resultDouble /= inputArray.length; 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.statbiginteger.PercentileBigIntegerTest.java
/** * Tests the plate statistics method using the values between the indices. *//*www.ja va 2 s .c om*/ @Test public void testPlateIndices() { for (PlateBigInteger plate : arrayIndices) { int inputPercentile = 1 + random.nextInt(100); int size = arrayIndices[0].first().size(); int begin = random.nextInt(size - 5); int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1); Map<WellBigInteger, BigDecimal> resultMap = new TreeMap<WellBigInteger, BigDecimal>(); Map<WellBigInteger, BigDecimal> returnedMap = percentile.plate(plate, begin, end - begin, inputPercentile); for (WellBigInteger 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.getPercentile(inputPercentile); BigDecimal result = new BigDecimal(resultDouble); resultMap.put(well, result); } for (WellBigInteger 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.statbiginteger.PercentileBigIntegerTest.java
/** * Tests set calculation using indices./*from www . ja v a 2 s . c o m*/ */ @Test public void testSetIndices() { for (PlateBigInteger plate : arrayIndices) { int inputPercentile = 1 + random.nextInt(100); int size = arrayIndices[0].first().size(); int begin = random.nextInt(size - 5); int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1); Map<WellBigInteger, BigDecimal> resultMap = new TreeMap<WellBigInteger, BigDecimal>(); Map<WellBigInteger, BigDecimal> returnedMap = percentile.set(plate.dataSet(), begin, end - begin, inputPercentile); for (WellBigInteger 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.getPercentile(inputPercentile); BigDecimal result = new BigDecimal(resultDouble); resultMap.put(well, result); } for (WellBigInteger 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.statbiginteger.PopulationVarianceBigIntegerTest.java
/** * Tests set calculation using indices.//from w w w . j av a 2s . c o m */ @Test public void testSetIndices() { for (PlateBigInteger 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<WellBigInteger, BigDecimal> resultMap = new TreeMap<WellBigInteger, BigDecimal>(); Map<WellBigInteger, BigDecimal> returnedMap = variance.set(plate.dataSet(), begin, end - begin, mc); for (WellBigInteger well : plate) { double[] input = new double[well.size()]; int index = 0; for (BigInteger bi : well) { input[index++] = bi.doubleValue(); } double[] inputArray = ArrayUtils.subarray(input, begin, end); DescriptiveStatistics stat = new DescriptiveStatistics(inputArray); double resultDouble = stat.getVariance(); resultDouble *= inputArray.length - 1; resultDouble /= inputArray.length; BigDecimal result = new BigDecimal(resultDouble); resultMap.put(well, result); } for (WellBigInteger 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.statbiginteger.SampleVarianceBigIntegerWeightsTest.java
/** * Tests well calculation./*from w w w . j a v a 2s .c om*/ */ @Test public void testWell() { for (PlateBigInteger plate : array) { for (WellBigInteger well : plate) { double[] input = new double[well.size()]; int index = 0; for (BigInteger bi : well) { input[index] = bi.doubleValue() * weights[index]; index++; } DescriptiveStatistics stat = new DescriptiveStatistics(input); double resultDouble = stat.getVariance(); BigDecimal returned = variance.well(well, weights, mc); BigDecimal result = new BigDecimal(resultDouble, mc); BigDecimal[] corrected = correctRoundingErrors(result, returned); assertEquals(corrected[0], corrected[1]); } } }
From source file:com.github.jessemull.microflexbiginteger.stat.SampleVarianceWeightsTest.java
/** * Tests well calculation./*from w w w. ja va 2s.co m*/ */ @Test public void testWell() { for (Plate plate : array) { for (Well well : plate) { double[] input = new double[well.size()]; int index = 0; for (BigInteger bi : well) { input[index] = bi.doubleValue() * weights[index]; index++; } DescriptiveStatistics stat = new DescriptiveStatistics(input); double resultDouble = stat.getVariance(); BigDecimal returned = variance.well(well, weights, mc); BigDecimal result = new BigDecimal(resultDouble, mc); BigDecimal[] corrected = correctRoundingErrors(result, returned); assertEquals(corrected[0], corrected[1]); } } }
From source file:com.github.jessemull.microflex.stat.statbiginteger.MeanBigIntegerWeightsTest.java
/** * Tests well calculation.//from www .j a v a 2s.co m */ @Test public void testWell() { for (PlateBigInteger plate : array) { for (WellBigInteger well : plate) { double[] input = new double[well.size()]; int index = 0; for (BigInteger bi : well) { input[index] = bi.doubleValue() * weights[index]; index++; } DescriptiveStatistics stat = new DescriptiveStatistics(input); double resultDouble = stat.getMean(); BigDecimal returned = mean.well(well, weights, mc); BigDecimal result = new BigDecimal(resultDouble, mc); BigDecimal[] corrected = correctRoundingErrors(returned, result); assertEquals(corrected[0], corrected[1]); } } }
From source file:com.github.jessemull.microflex.stat.statbiginteger.SumBigIntegerWeightsTest.java
/** * Tests well calculation.//from w ww . j av a2 s .com */ @Test public void testWell() { for (PlateBigInteger plate : array) { for (WellBigInteger well : plate) { double[] input = new double[well.size()]; int index = 0; for (BigInteger bi : well) { input[index] = bi.doubleValue() * weights[index]; index++; } DescriptiveStatistics stat = new DescriptiveStatistics(input); double resultDouble = stat.getSum(); BigDecimal returned = sum.well(well, weights, mc); BigDecimal result = new BigDecimal(resultDouble, mc); BigDecimal[] corrected = correctRoundingErrors(returned, result); assertEquals(corrected[0], corrected[1]); } } }
From source file:com.github.jessemull.microflex.stat.statbiginteger.SumOfSquaresBigIntegerWeightsTest.java
/** * Tests well calculation./*from w w w .ja v a 2 s .c o m*/ */ @Test public void testWell() { for (PlateBigInteger plate : array) { for (WellBigInteger well : plate) { double[] input = new double[well.size()]; int index = 0; for (BigInteger bi : well) { input[index] = bi.doubleValue() * weights[index]; index++; } DescriptiveStatistics stat = new DescriptiveStatistics(input); double resultDouble = stat.getSumsq(); BigDecimal returned = sum.well(well, weights, mc); BigDecimal result = new BigDecimal(resultDouble, mc); BigDecimal[] corrected = correctRoundingErrors(returned, result); assertEquals(corrected[0], corrected[1]); } } }
From source file:com.github.jessemull.microflexbiginteger.stat.MeanWeightsTest.java
/** * Tests well calculation.//from w w w. ja v a 2 s . c o m */ @Test public void testWell() { for (Plate plate : array) { for (Well well : plate) { double[] input = new double[well.size()]; int index = 0; for (BigInteger bi : well) { input[index] = bi.doubleValue() * weights[index]; index++; } DescriptiveStatistics stat = new DescriptiveStatistics(input); double resultDouble = stat.getMean(); BigDecimal returned = mean.well(well, weights, mc); BigDecimal result = new BigDecimal(resultDouble, mc); BigDecimal[] corrected = correctRoundingErrors(returned, result); assertEquals(corrected[0], corrected[1]); } } }