List of usage examples for java.math BigDecimal doubleValue
@Override public double doubleValue()
From source file:com.github.jessemull.microflexbigdecimal.stat.KurtosisTest.java
/** * Tests set calculation using indices.//from w ww .j a v a 2 s . com */ @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 = kurtosis.set(plate.dataSet(), 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(); } 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.microflexbigdecimal.stat.SampleVarianceTest.java
/** * Tests the plate statistics method./*from w w w . j a v a 2 s .c o m*/ */ @Test public void testPlate() { for (Plate plate : array) { Map<Well, BigDecimal> resultMap = new TreeMap<Well, BigDecimal>(); Map<Well, BigDecimal> returnedMap = variance.plate(plate, mc); for (Well well : plate) { double[] input = new double[well.size()]; int index = 0; for (BigDecimal bd : well) { input[index++] = bd.doubleValue(); } DescriptiveStatistics stat = new DescriptiveStatistics(input); double resultDouble = stat.getVariance(); 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.microflexbigdecimal.stat.SkewnessTest.java
/** * Tests the plate statistics method using the values between the indices. *//*from www . j av a 2 s. c om*/ @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 (BigDecimal bd : well) { input[index++] = bd.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.microflexbigdecimal.stat.SkewnessTest.java
/** * Tests set calculation using indices./*from w w w. j a v a 2s.com*/ */ @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 = skewness.set(plate.dataSet(), 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(); } 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.microflexbigdecimal.stat.StandardDeviationTest.java
/** * Tests the plate statistics method using the values between the indices. *///from w w w .j a v a 2s .c om @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 = deviation.plate(plate, 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(); } DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end)); double resultDouble = stat.getStandardDeviation(); 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.microflexbigdecimal.stat.StandardDeviationTest.java
/** * Tests set calculation using indices./* ww w. ja v a2s .co m*/ */ @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 = deviation.set(plate.dataSet(), 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(); } DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end)); double resultDouble = stat.getStandardDeviation(); 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.statbigdecimal.SampleVarianceBigDecimalTest.java
/** * Tests set calculation./* w ww . j a v a2 s. c o m*/ */ @Test public void testSet() { for (PlateBigDecimal plate : array) { Map<WellBigDecimal, BigDecimal> resultMap = new TreeMap<WellBigDecimal, BigDecimal>(); Map<WellBigDecimal, BigDecimal> returnedMap = variance.set(plate.dataSet(), mc); for (WellBigDecimal well : plate) { double[] input = new double[well.size()]; int index = 0; for (BigDecimal bd : well) { input[index++] = bd.doubleValue(); } DescriptiveStatistics stat = new DescriptiveStatistics(input); double resultDouble = stat.getVariance(); BigDecimal result = new BigDecimal(resultDouble); 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.SampleVarianceTest.java
/** * Tests set calculation.//from ww w . j a v a2 s. c o m */ @Test public void testSet() { for (Plate plate : array) { Map<Well, BigDecimal> resultMap = new TreeMap<Well, BigDecimal>(); Map<Well, BigDecimal> returnedMap = variance.set(plate.dataSet(), mc); for (Well well : plate) { double[] input = new double[well.size()]; int index = 0; for (BigDecimal bd : well) { input[index++] = bd.doubleValue(); } DescriptiveStatistics stat = new DescriptiveStatistics(input); double resultDouble = stat.getVariance(); 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.mobileman.projecth.web.service.PatientDataService.java
private void prepareKpi(DataHolder data, Model model, User patient, Disease disease) { //find kpitype if (disease == null) { return;// ww w. j a va2 s. co m } Date dateFrom = data.getDateFrom(); Date dateTo = data.getDateTo(); List<KeyPerformanceIndicatorType> kpis = keyPerformanceIndicatorTypeService.findAll(disease.getId()); if (kpis == null || kpis.size() == 0) { return; } List<Object[]> result = new ArrayList<Object[]>(); model.addAttribute("kpis", result); for (KeyPerformanceIndicatorType kpi : kpis) { Object[] re = new Object[4]; boolean add = false; re[0] = kpi; //model.addAttribute("kpi_title", kpi.getDescription()); //model.addAttribute("kpi_code", kpi.getCode()); //Patient patient = data.getPatient(); BigDecimal kpiResult = patientKPIService.computeKPI(patient.getId(), kpi.getId(), dateFrom, dateTo); if (kpiResult != null) { double rounded = Math.round(kpiResult.doubleValue() * 100.0) / 100.0; //model.addAttribute("kpi_value", rounded); re[1] = rounded; add = true; } //calculated List<KeyPerformanceIndicatorStatistics> kpiData = patientKPIService.computeKPITimeline(patient.getId(), kpi.getId(), data.getDateFrom(), data.getDateTo()); //data //double if (kpiData != null) { List<String> rc = new ArrayList<String>(); rc.add(AbstractPrepareChartData.getDateInfo(data.getDateFrom(), -1, null, null)); for (KeyPerformanceIndicatorStatistics obj : kpiData) { rc.add(AbstractPrepareChartData.getDateInfo(obj.getDate(), 0, obj.getValue().toString().replace(',', '.'), null)); } rc.add(AbstractPrepareChartData.getDateInfo(data.getDateFrom(), 1, null, null)); re[2] = rc; add = true; } //modified for chart if (data.getType() == UserType.D) { List<PatientKeyPerformanceIndicatorValidation> cdais = patientKPIValidationService .findValidatedValues(data.getPatient().getId(), kpi.getId(), data.getDateFrom(), data.getDateTo()); List<String> result2 = new ArrayList<String>(); model.addAttribute("modified_kpi", result2); result2.add(AbstractPrepareChartData.getDateInfo(data.getDateFrom(), -1, null, null)); for (PatientKeyPerformanceIndicatorValidation validation : cdais) { if (validation.getValue() != null) { result2.add(AbstractPrepareChartData.getDateInfo(validation.getLogDate(), 0, Double.toString(Math.round(validation.getValue().doubleValue() * 100.0) / 100.0) .replace(',', '.'), null)); } } result2.add(AbstractPrepareChartData.getDateInfo(data.getDateFrom(), 1, null, null)); re[3] = result2; add = true; } if (add) { result.add(re); } } }
From source file:com.github.jessemull.microflex.stat.statbigdecimal.SampleVarianceBigDecimalTest.java
/** * Tests the plate statistics method using the values between the indices. *//* w w w .j a v a 2 s . c o m*/ @Test public void testPlateIndices() { for (PlateBigDecimal 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<WellBigDecimal, BigDecimal> resultMap = new TreeMap<WellBigDecimal, BigDecimal>(); Map<WellBigDecimal, BigDecimal> returnedMap = variance.plate(plate, 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(); } double[] inputArray = ArrayUtils.subarray(input, begin, end); DescriptiveStatistics stat = new DescriptiveStatistics(inputArray); double resultDouble = stat.getVariance(); BigDecimal result = new BigDecimal(resultDouble); 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]); } } }