private void setNorm( double medDepth, List<String> bad, Map<String, Double> factor2, Map<String, Double> sampleMedian) { for (Map.Entry<String, Map<String, Sample>> entry : samples.entrySet()) { if (!bad.contains(entry.getKey())) { for (Map.Entry<String, Sample> entrySample : entry.getValue().entrySet()) { Sample sample = entrySample.getValue(); double norm1 = sample.getNorm1(); double fact2 = factor2.get(entry.getKey()); double smplMed = sampleMedian.get(sample.getSample()); sample.setNorm1b(Precision.round(norm1 * fact2 + 0.1, 2)); sample.setNorm2( Precision.round( medDepth != 0 ? log.value((norm1 * fact2 + 0.1) / medDepth) / log.value(2) : 0, 2)); sample.setNorm3( Precision.round( smplMed != 0 ? log.value((norm1 * fact2 + 0.1) / smplMed) / log.value(2) : 0, 2)); } } } }
private double getMedDepth(double[] depth, Set<String> samp) { int i = 0; for (Map.Entry<String, Map<String, Sample>> entry : samples.entrySet()) { Map<String, Sample> sampleMap = entry.getValue(); for (Map.Entry<String, Sample> sampleEntry : sampleMap.entrySet()) { Sample sample = sampleEntry.getValue(); double norm1 = Precision.round((sample.getCov() * factor.get(sample.getSample())), 2); sample.setNorm1(norm1); depth[i++] = norm1; samp.add(sample.getSample()); } } return median.evaluate(depth); }
protected void initialize( double dLatResolution, double dLonResolution, Range<Double> rngLat, Range<Double> rngLon, String sVarName, String sVarUnits) { // i1 = current counter // d1 = current value being added to map // iMax = maximum value for counter int i1; int iMax; double d1; // saving variables this.sVarName = sVarName; this.sVarUnits = sVarUnits; // this.plyMask = plyMask; this.dLatResolution = dLatResolution; this.dLonResolution = dLonResolution; this.rngLat = rngLat; this.rngLon = rngLon; // loading treemaps mapLat = new TreeMap<Double, Integer>(); mapLon = new TreeMap<Double, Integer>(); mapDate = new TreeMap<LocalDate, Integer>(); mapDate.put(NULL_TIME, 0); mapVert = new TreeMap<Double, Integer>(); mapVert.put(NULL_VERT, 0); // initializing indices iDateIndex = 1; iVertIndex = 1; iMax = 0; for (int i = 0; i < (rngLat.upperEndpoint() - rngLat.lowerEndpoint()) / dLatResolution + 5; i++) { d1 = Precision.round(i * dLatResolution + rngLat.lowerEndpoint(), 9); if (d1 > rngLat.upperEndpoint() - dLatResolution) { break; } iMax++; } i1 = 0; for (int i = 0; i < (rngLat.upperEndpoint() - rngLat.lowerEndpoint()) / dLatResolution + 5; i++) { d1 = Precision.round(i * dLatResolution + rngLat.lowerEndpoint(), 9); if (d1 > rngLat.upperEndpoint() - dLatResolution) { break; } mapLat.put(d1, iMax - i1 - 1); i1++; } i1 = 0; for (int i = 0; i < (rngLon.upperEndpoint() - rngLon.lowerEndpoint()) / dLonResolution + 5; i++) { d1 = Precision.round(i * dLonResolution + rngLon.lowerEndpoint(), 9); if (d1 > rngLon.upperEndpoint() - dLonResolution) { break; } mapLon.put(d1, i1); i1++; } iRows = mapLat.size(); iCols = mapLon.size(); lstCoords = new ArrayList<GeoCoordinate>(10000); }
@Override public double calcPay() { // need?? double rounded = Precision.round((salary / 24), 2, BigDecimal.ROUND_HALF_DOWN); return rounded; }
/** * The real and imaginary values of the given Complex are rounded to precision * * @param complex * @param precision */ public ComplexValue(Complex complex, int precision) { real = BigDecimal.valueOf(Precision.round(complex.getReal(), precision)); imaginary = BigDecimal.valueOf(Precision.round(complex.getImaginary(), precision)); }