List of usage examples for java.lang Double MAX_VALUE
double MAX_VALUE
To view the source code for java.lang Double MAX_VALUE.
Click Source Link
From source file:com.twitter.heron.healthmgr.common.ComponentMetricsHelper.java
public MetricsStats computeMinMaxStats(String metric) { double metricMax = 0; double metricMin = Double.MAX_VALUE; for (InstanceMetrics instance : componentMetrics.getMetrics().values()) { Double metricValue = instance.getMetricValueSum(metric); if (metricValue == null) { continue; }/*from w ww.j a v a 2 s . co m*/ metricMax = metricMax < metricValue ? metricValue : metricMax; metricMin = metricMin > metricValue ? metricValue : metricMin; } return new MetricsStats(metricMin, metricMax); }
From source file:de.biomedical_imaging.ij.nanotrackj.WalkerMethodEstimator.java
/** * //from www .ja va 2 s . com * @param data Containes the mean squared displacement and the Tracklength for each track. data[i][0] = MSD data[i][1] = Tracklength * @param temp Temperature of the suspension in kelvin * @param visk Viscosity of the suspension * @param framerate * @param maxdiameter The maximum diameter for the estimation. 0 = Maximum Diameter is estimated automatically */ public WalkerMethodEstimator(double[][] data, double temp, double visk, double framerate, int maxdiameter) { this.temp = temp; this.visk = visk; this.framerate = 1.0 / framerate; this.data = data; kMin = Integer.MAX_VALUE; kMax = Integer.MIN_VALUE; msdMin = Double.MAX_VALUE; msdMax = Double.MIN_VALUE; double convFact = Math.pow(10, -10); for (int i = 0; i < data.length; i++) { //10^-10 cm^2 -> cm^2 this.data[i][0] = this.data[i][0] * convFact; //- 4*17.562862475*17.562862475*Math.pow(10, -7)*Math.pow(10, -7); if (this.data[i][0] > msdMax) { msdMax = this.data[i][0]; } if (this.data[i][0] < msdMin) { msdMin = this.data[i][0]; } if (this.data[i][1] > kMax) { kMax = (int) this.data[i][1]; } if (this.data[i][1] < kMin) { kMin = (int) this.data[i][1]; } //IJ.log("MSD " + this.data[i][0]); } logMapK = new double[kMax + 1]; logMapGammaK = new double[kMax + 1]; java.util.Arrays.fill(logMapK, Double.NaN); java.util.Arrays.fill(logMapGammaK, Double.NaN); maxRadiusInNm = maxdiameter / 2.0; if (maxdiameter == 0) { maxRadiusInNm = NanoTrackJ_.getInstance() .diffCoeffToDiameter((msdMin * Math.pow(10, 10)) / 4 * (framerate)); maxRadiusInNm = (maxRadiusInNm + 1) / 2; } binNumber = (int) (maxRadiusInNm / binSizeInnm); histBinNumber = (int) Math.ceil(Math.sqrt(data.length)); deltaB = msdMax / histBinNumber; histogramMSD = new double[histBinNumber]; java.util.Arrays.fill(histogramMSD, 0); Nk = new int[kMax + 1]; java.util.Arrays.fill(Nk, 0); for (int i = 0; i < data.length; i++) { int index = (int) this.data[i][1]; Nk[index]++; int index2 = (int) Math.floor(data[i][0] / deltaB - 0.001); histogramMSD[index2]++; } }
From source file:com.github.rinde.rinsim.util.StochasticSuppliersTest.java
/** * Tests for/* w w w . j a va 2s . c o m*/ * {@link StochasticSuppliers#checked(StochasticSupplier, Predicate)}. */ @Test public void testCheckedSupplier() { final Predicate<Double> positive = Range.closedOpen(0d, Double.POSITIVE_INFINITY); checked(constant(0d), positive).get(0); checked(constant(453453453.34), positive).get(0); checked(constant(Double.MAX_VALUE), positive).get(0); boolean fail = false; try { checked(constant(Double.POSITIVE_INFINITY), positive).get(0); } catch (final IllegalArgumentException e) { fail = true; } assertTrue(fail); fail = false; try { checked(constant(-0.0000000001), positive).get(0); } catch (final IllegalArgumentException e) { fail = true; } assertTrue(fail); }
From source file:co.turnus.common.util.CommonDataUtil.java
public static <T> double minOf(EMap<T, StatisticalData> map) { double val = Double.MAX_VALUE; for (Entry<T, StatisticalData> s : map.entrySet()) { val = FastMath.min(val, s.getValue().getMin()); }//from w w w . ja v a 2 s.c o m return val; }
From source file:edu.oregonstate.eecs.mcplan.domains.voyager.policies.ExpandPolicy.java
@Override public VoyagerAction getAction() { Planet src = null;/* w w w. j av a 2s. c o m*/ int workers = 1; // Only consider planets with >1 worker for (final Planet p : s_.planets) { if (p.owner() == self_ && p.population(Unit.Worker) > workers) { src = p; workers = p.population(Unit.Worker); } } if (src != null) { Planet dest = null; double d = Double.MAX_VALUE; for (final Planet p : s_.planets) { if (p.owner() == Player.Neutral && Voyager.sq_distance(src, p) < d) { dest = p; d = Voyager.sq_distance(src, dest); } } if (dest != null) { final int[] pop = new int[Unit.values().length]; // Guaranteed to be at least 1 pop[Unit.Worker.ordinal()] = src.population(Unit.Worker) / 2; return new LaunchAction(src, dest, pop); } } return new NothingAction(); }
From source file:clus.pruning.C45Pruner.java
public void pruneC45Recursive(ClusNode node, RowData data) throws ClusException { if (!node.atBottomLevel()) { // first prune all child trees NodeTest tst = node.getTest();/*from ww w . j a va2s .c o m*/ for (int i = 0; i < node.getNbChildren(); i++) { ClusNode child = (ClusNode) node.getChild(i); RowData subset = data.applyWeighted(tst, i); pruneC45Recursive(child, subset); } // compute largest branch index double errorsLargestBranch = 0.0; int indexOfLargestBranch = node.getLargestBranchIndex(); if (m_SubTreeRaising) { ClusNode largest = (ClusNode) node.getChild(indexOfLargestBranch); errorsLargestBranch = getEstimatedErrorsForBranch(largest, data); } else { errorsLargestBranch = Double.MAX_VALUE; } // Compute error if this Tree would be leaf double errorsLeaf = getEstimatedErrorsForDistribution((ClassificationStat) node.getTargetStat()); // Compute error for the whole subtree double errorsTree = getEstimatedErrors(node); // Decide if leaf is best choice. if (ClusUtil.smOrEq(errorsLeaf, errorsTree + 0.1) && ClusUtil.smOrEq(errorsLeaf, errorsLargestBranch + 0.1)) { node.makeLeaf(); return; } // Decide if largest branch is better choice than whole subtree. if (ClusUtil.smOrEq(errorsLargestBranch, errorsTree + 0.1)) { ClusNode largest = (ClusNode) node.getChild(indexOfLargestBranch); node.makeLeaf(); node.setTest(largest.getTest()); node.setNbChildren(largest.getNbChildren()); for (int i = 0; i < largest.getNbChildren(); i++) { node.setChild(largest.getChild(i), i); } node.adaptToData(data); pruneC45Recursive(node, data); } } }
From source file:net.semanticmetadata.lire.solr.LireValueSourceParser.java
@Override public ValueSource parse(FunctionQParser fp) throws SyntaxError { String field = fp.parseArg(); // eg. cl_hi String featureString = fp.parseArg(); // System.out.println(featureString); byte[] hist = Base64.decodeBase64(featureString); // eg. FQY5DhMYDg0ODg0PEBEPDg4ODg8QEgsgEBAQEBAgEBAQEBA= double maxDistance = Double.MAX_VALUE; if (fp.hasMoreArguments()) { // if there is a third argument, it's the max value to return if there is none. Note the query cache is not updated upon parameter change. maxDistance = Double.parseDouble(fp.parseArg()); }//from ww w.ja v a 2 s . co m return new LireValueSource(field, hist, maxDistance); }
From source file:edu.illinois.cs.cogcomp.utils.Utils.java
/** * This is a measure used by NEWS2015.//ww w .j a v a 2 s . com * @param prediction * @param referents * @return */ public static double GetFuzzyF1(String prediction, List<String> referents) { // calculate Fuzzy F1 String cand = prediction; double bestld = Double.MAX_VALUE; String bestref = ""; for (String reference : referents) { double ld = LevensteinDistance.getLevensteinDistance(reference, cand); if (ld < bestld) { bestref = reference; bestld = ld; } } double lcs = (cand.length() + bestref.length() - bestld) * 0.5; double R = lcs / bestref.length(); double P = lcs / cand.length(); double F1 = 2 * R * P / (R + P); return F1; }
From source file:es.udc.gii.common.eaf.benchmark.log.FesGNELogTool.java
private double calculateGNE(Individual best, BenchmarkObjectiveFunction objective) { double aux_gne, gne; double[] chromosome; double[][] optimums; chromosome = best.getChromosomeAt(0); optimums = objective.getOptimum(chromosome.length); //Se calcula el gne para el primer optimo: gne = 0;//from ww w .j a va 2 s. c o m for (int i = 0; i < chromosome.length; i++) { gne += Math.pow(chromosome[i] - optimums[0][i], 2.0); } gne /= chromosome.length; gne = Math.sqrt(gne); //Si hay ms ptimos nos quedamos con el menos error de todos: aux_gne = Double.MAX_VALUE; if (optimums.length > 1) { for (int j = 1; j < optimums.length; j++) { aux_gne = 0; for (int k = 0; k < chromosome.length; k++) { aux_gne += Math.pow(chromosome[k] - optimums[j][k], 2.0); } aux_gne /= chromosome.length; aux_gne = Math.sqrt(gne); } gne = Math.min(gne, aux_gne); } return gne; }
From source file:edu.fullerton.viewerplugin.XYPlotter.java
private ChartPanel getPanel(double[][] data) throws WebUtilException { ChartPanel ret = null;/*from w w w .j av a 2s . c om*/ try { XYSeries xys; XYSeriesCollection mtds = new XYSeriesCollection(); String mylegend = legend == null || legend.isEmpty() ? "series 1" : legend; xys = new XYSeries(legend); int len = data.length; double minx = Double.MAX_VALUE; double maxx = Double.MIN_VALUE; double miny = Double.MAX_VALUE; double maxy = Double.MIN_VALUE; boolean gotZeroX = false; boolean gotZeroY = false; for (int i = 0; i < len; i++) { double x = data[i][0]; double y = data[i][1]; if (x == 0) { gotZeroX = true; } else { minx = Math.min(minx, x); maxx = Math.max(maxx, x); } if (y == 0) { gotZeroY = true; } else { miny = Math.min(miny, y); maxy = Math.max(maxy, y); } } // this kludge lets us plot a 0 on a log axis double fakeZeroX = 0.; double fakeZeroY = 0.; if (gotZeroX) { if (logXaxis) { fakeZeroX = minx / 10; } else { minx = Math.min(0, minx); maxx = Math.max(0, maxx); } } if (gotZeroY) { if (logYaxis) { fakeZeroY = miny / 10; } else { miny = Math.min(0, miny); maxy = Math.max(0, maxy); } } for (int i = 0; i < len; i++) { double x = data[i][0]; double y = data[i][1]; x = x == 0 ? fakeZeroX : x; y = y == 0 ? fakeZeroY : y; xys.add(x, y); } mtds.addSeries(xys); DefaultXYDataset ds = new DefaultXYDataset(); int exp; if (maxy == 0. && miny == 0.) { miny = -1.; exp = 0; logYaxis = false; } else { maxy = maxy > miny ? maxy : miny * 10; exp = PluginSupport.scaleRange(mtds, miny, maxy); if (!logYaxis && exp > 0) { yLabel += " x 1e-" + Integer.toString(exp); } } JFreeChart chart = ChartFactory.createXYLineChart(title, xLabel, yLabel, ds, PlotOrientation.VERTICAL, true, false, false); org.jfree.chart.plot.XYPlot plot = (org.jfree.chart.plot.XYPlot) chart.getPlot(); if (logYaxis) { LogAxis rangeAxis = new LogAxis(yLabel); double smallest = miny * Math.pow(10, exp); rangeAxis.setSmallestValue(smallest); rangeAxis.setMinorTickCount(9); LogAxisNumberFormat lanf = new LogAxisNumberFormat(); lanf.setExp(exp); rangeAxis.setNumberFormatOverride(lanf); rangeAxis.setRange(smallest, maxy * Math.pow(10, exp)); plot.setRangeAxis(rangeAxis); } if (logXaxis) { LogAxis domainAxis = new LogAxis(xLabel); domainAxis.setMinorTickCount(9); domainAxis.setSmallestValue(minx); domainAxis.setNumberFormatOverride(new LogAxisNumberFormat()); plot.setDomainAxis(domainAxis); } ValueAxis domainAxis = plot.getDomainAxis(); if (fmin != null && fmin > 0) { domainAxis.setLowerBound(fmin); } if (fmax != null && fmax > 0) { domainAxis.setUpperBound(fmax); } plot.setDomainAxis(domainAxis); plot.setDataset(0, mtds); // Set the line thickness XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer(); BasicStroke str = new BasicStroke(lineThickness); int n = plot.getSeriesCount(); for (int i = 0; i < n; i++) { r.setSeriesStroke(i, str); } if (legend == null || legend.isEmpty()) { chart.removeLegend(); } ret = new ChartPanel(chart); } catch (Exception ex) { throw new WebUtilException("Creating spectrum plot" + ex.getLocalizedMessage()); } return ret; }