List of usage examples for java.math BigDecimal doubleValue
@Override public double doubleValue()
From source file:com.github.jessemull.microflexbigdecimal.stat.SumOfSquaresWeightsTest.java
/** * Tests set calculation./* w ww. j a v a 2 s . c o m*/ */ @Test public void testSet() { for (Plate plate : array) { Map<Well, BigDecimal> resultMap = new TreeMap<Well, BigDecimal>(); Map<Well, BigDecimal> returnedMap = sum.set(plate.dataSet(), weights, mc); for (Well well : plate) { double[] input = new double[well.size()]; int index = 0; for (BigDecimal bd : well) { input[index] = bd.doubleValue() * weights[index]; index++; } DescriptiveStatistics stat = new DescriptiveStatistics(input); double resultDouble = stat.getSumsq(); BigDecimal result = new BigDecimal(resultDouble, mc); 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.microflexbigdecimal.stat.SumWeightsTest.java
/** * Tests set calculation.// w ww . jav a2s . c o m */ @Test public void testSet() { for (Plate plate : array) { Map<Well, BigDecimal> resultMap = new TreeMap<Well, BigDecimal>(); Map<Well, BigDecimal> returnedMap = sum.set(plate.dataSet(), weights, mc); for (Well well : plate) { double[] input = new double[well.size()]; int index = 0; for (BigDecimal bd : well) { input[index] = bd.doubleValue() * weights[index]; index++; } DescriptiveStatistics stat = new DescriptiveStatistics(input); double resultDouble = stat.getSum(); BigDecimal result = new BigDecimal(resultDouble, mc); 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.statbigdecimal.SampleVarianceBigDecimalWeightsTest.java
/** * Tests the plate statistics method using the values between the indices. *///from www .j av a 2 s .com @Test public void testPlateIndices() { for (PlateBigDecimal plate : arrayIndices) { int begin = random.nextInt(plate.first().size() - 4); int end = begin + random.nextInt(3) + 3; Map<WellBigDecimal, BigDecimal> resultMap = new TreeMap<WellBigDecimal, BigDecimal>(); Map<WellBigDecimal, BigDecimal> returnedMap = variance.plate(plate, ArrayUtils.subarray(weightsIndices, begin, end), begin, end - begin, mc); for (WellBigDecimal well : plate) { double[] input = new double[well.size()]; int index = 0; for (BigDecimal bd : well) { input[index] = bd.doubleValue() * weightsIndices[index]; index++; } DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end)); double resultDouble = stat.getVariance(); BigDecimal result = new BigDecimal(resultDouble, mc); resultMap.put(well, result); } for (WellBigDecimal 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.statbigdecimal.SampleVarianceBigDecimalWeightsTest.java
/** * Tests set calculation using indices.//from w w w . j ava2s . c o m */ @Test public void testSetIndices() { for (PlateBigDecimal plate : arrayIndices) { int begin = random.nextInt(plate.first().size() - 4); int end = begin + random.nextInt(3) + 3; Map<WellBigDecimal, BigDecimal> resultMap = new TreeMap<WellBigDecimal, BigDecimal>(); Map<WellBigDecimal, BigDecimal> returnedMap = variance.set(plate.dataSet(), ArrayUtils.subarray(weightsIndices, begin, end), begin, end - begin, mc); for (WellBigDecimal well : plate) { double[] input = new double[well.size()]; int index = 0; for (BigDecimal bd : well) { input[index] = bd.doubleValue() * weightsIndices[index]; index++; } DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end)); double resultDouble = stat.getVariance(); BigDecimal result = new BigDecimal(resultDouble, mc); resultMap.put(well, result); } for (WellBigDecimal 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.microflexbigdecimal.stat.SampleVarianceWeightsTest.java
/** * Tests the plate statistics method using the values between the indices. *//*from ww w. j av a 2s .co 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, BigDecimal> resultMap = new TreeMap<Well, BigDecimal>(); Map<Well, BigDecimal> returnedMap = variance.plate(plate, ArrayUtils.subarray(weightsIndices, begin, end), begin, end - begin, mc); for (Well well : plate) { double[] input = new double[well.size()]; int index = 0; for (BigDecimal bd : well) { input[index] = bd.doubleValue() * weightsIndices[index]; index++; } DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end)); double resultDouble = stat.getVariance(); BigDecimal result = new BigDecimal(resultDouble, mc); 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.microflexbigdecimal.stat.SampleVarianceWeightsTest.java
/** * Tests set calculation using indices.//from w w w .j ava 2s.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, BigDecimal> resultMap = new TreeMap<Well, BigDecimal>(); Map<Well, BigDecimal> returnedMap = variance.set(plate.dataSet(), ArrayUtils.subarray(weightsIndices, begin, end), begin, end - begin, mc); for (Well well : plate) { double[] input = new double[well.size()]; int index = 0; for (BigDecimal bd : well) { input[index] = bd.doubleValue() * weightsIndices[index]; index++; } DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end)); double resultDouble = stat.getVariance(); BigDecimal result = new BigDecimal(resultDouble, mc); 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.statbigdecimal.MeanBigDecimalWeightsTest.java
/** * Tests the plate statistics method using the values between the indices. *///from w ww . java 2s . c o m @Test public void testPlateIndices() { for (PlateBigDecimal plate : arrayIndices) { int begin = random.nextInt(plate.first().size() - 4); int end = begin + random.nextInt(3) + 3; Map<WellBigDecimal, BigDecimal> resultMap = new TreeMap<WellBigDecimal, BigDecimal>(); Map<WellBigDecimal, BigDecimal> returnedMap = mean.plate(plate, ArrayUtils.subarray(weightsIndices, begin, end), begin, end - begin, mc); for (WellBigDecimal well : plate) { double[] input = new double[well.size()]; int index = 0; for (BigDecimal bd : well) { input[index] = bd.doubleValue() * weightsIndices[index]; index++; } DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end)); double resultDouble = stat.getMean(); BigDecimal result = new BigDecimal(resultDouble, mc); resultMap.put(well, result); } for (WellBigDecimal 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.statbigdecimal.MeanBigDecimalWeightsTest.java
/** * Tests set calculation using indices.//w ww.ja v a 2 s. c o m */ @Test public void testSetIndices() { for (PlateBigDecimal plate : arrayIndices) { int begin = random.nextInt(plate.first().size() - 4); int end = begin + random.nextInt(3) + 3; Map<WellBigDecimal, BigDecimal> resultMap = new TreeMap<WellBigDecimal, BigDecimal>(); Map<WellBigDecimal, BigDecimal> returnedMap = mean.set(plate.dataSet(), ArrayUtils.subarray(weightsIndices, begin, end), begin, end - begin, mc); for (WellBigDecimal well : plate) { double[] input = new double[well.size()]; int index = 0; for (BigDecimal bd : well) { input[index] = bd.doubleValue() * weightsIndices[index]; index++; } DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end)); double resultDouble = stat.getMean(); BigDecimal result = new BigDecimal(resultDouble, mc); resultMap.put(well, result); } for (WellBigDecimal 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.statbigdecimal.SumBigDecimalWeightsTest.java
/** * Tests the plate statistics method using the values between the indices. *///from w w w . j a va 2s . co m @Test public void testPlateIndices() { for (PlateBigDecimal plate : arrayIndices) { int begin = random.nextInt(plate.first().size() - 4); int end = begin + random.nextInt(3) + 3; Map<WellBigDecimal, BigDecimal> resultMap = new TreeMap<WellBigDecimal, BigDecimal>(); Map<WellBigDecimal, BigDecimal> returnedMap = sum.plate(plate, ArrayUtils.subarray(weightsIndices, begin, end), begin, end - begin, mc); for (WellBigDecimal well : plate) { double[] input = new double[well.size()]; int index = 0; for (BigDecimal bd : well) { input[index] = bd.doubleValue() * weightsIndices[index]; index++; } DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end)); double resultDouble = stat.getSum(); BigDecimal result = new BigDecimal(resultDouble, mc); resultMap.put(well, result); } for (WellBigDecimal 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.statbigdecimal.SumBigDecimalWeightsTest.java
/** * Tests set calculation using indices.//from w w w .j a v a 2 s .co m */ @Test public void testSetIndices() { for (PlateBigDecimal plate : arrayIndices) { int begin = random.nextInt(plate.first().size() - 4); int end = begin + random.nextInt(3) + 3; Map<WellBigDecimal, BigDecimal> resultMap = new TreeMap<WellBigDecimal, BigDecimal>(); Map<WellBigDecimal, BigDecimal> returnedMap = sum.set(plate.dataSet(), ArrayUtils.subarray(weightsIndices, begin, end), begin, end - begin, mc); for (WellBigDecimal well : plate) { double[] input = new double[well.size()]; int index = 0; for (BigDecimal bd : well) { input[index] = bd.doubleValue() * weightsIndices[index]; index++; } DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end)); double resultDouble = stat.getSum(); BigDecimal result = new BigDecimal(resultDouble, mc); resultMap.put(well, result); } for (WellBigDecimal well : plate) { BigDecimal result = resultMap.get(well); BigDecimal returned = returnedMap.get(well); BigDecimal[] corrected = correctRoundingErrors(result, returned); assertEquals(corrected[0], corrected[1]); } } }