List of usage examples for java.lang Double MIN_VALUE
double MIN_VALUE
To view the source code for java.lang Double MIN_VALUE.
Click Source Link
From source file:org.thymeleaf.util.EvaluationUtilTest.java
@Test public void convertToBooleanTest() { Assert.assertFalse(EvaluationUtil.evaluateAsBoolean(null)); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Boolean.TRUE)); Assert.assertFalse(EvaluationUtil.evaluateAsBoolean(Boolean.FALSE)); Assert.assertFalse(EvaluationUtil.evaluateAsBoolean(BigDecimal.ZERO)); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(BigDecimal.ONE)); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(BigDecimal.TEN)); Assert.assertFalse(EvaluationUtil.evaluateAsBoolean(BigInteger.ZERO)); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(BigInteger.ONE)); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(BigInteger.TEN)); Assert.assertFalse(EvaluationUtil.evaluateAsBoolean(Double.valueOf(0.0d))); Assert.assertFalse(EvaluationUtil.evaluateAsBoolean(Float.valueOf(0.0f))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Double.valueOf(0.1d))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Float.valueOf(0.1f))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Double.valueOf(-0.1d))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Float.valueOf(-0.1f))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Double.valueOf(Double.MAX_VALUE))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Float.valueOf(Float.MAX_VALUE))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Double.valueOf(Double.MIN_VALUE))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Float.valueOf(Float.MIN_VALUE))); Assert.assertFalse(EvaluationUtil.evaluateAsBoolean(Character.valueOf((char) 0))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Character.valueOf('x'))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Character.valueOf('0'))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Character.valueOf('1'))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean("true")); Assert.assertFalse(EvaluationUtil.evaluateAsBoolean("false")); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean("yes")); Assert.assertFalse(EvaluationUtil.evaluateAsBoolean("no")); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean("on")); Assert.assertFalse(EvaluationUtil.evaluateAsBoolean("off")); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean("sky")); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean("high above")); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(new LiteralValue("true"))); Assert.assertFalse(EvaluationUtil.evaluateAsBoolean(new LiteralValue("false"))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(new LiteralValue("yes"))); Assert.assertFalse(EvaluationUtil.evaluateAsBoolean(new LiteralValue("no"))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(new LiteralValue("on"))); Assert.assertFalse(EvaluationUtil.evaluateAsBoolean(new LiteralValue("off"))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(new LiteralValue("sky"))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(new LiteralValue("high above"))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(EvaluationUtil.class)); }
From source file:cmsc105_mp2.Panels.java
public void createGraph(Data d, float window, Double threshold) { XYSeries data = new XYSeries("data"); double max = Double.MIN_VALUE; for (double num : d.plots) { if (max < num) max = num;//from w ww . ja v a 2 s.c om } max += 1; ArrayList<XYSeries> xy = new ArrayList(); ArrayList<Integer> points = new ArrayList(); for (int j = (int) (window / 2); j < d.plots.length - (window / 2); j++) { data.add(j, d.plots[j]); //System.out.println(points.size()); if (d.plots[j] > threshold) { points.add(j); } else { if (points.size() >= window) { //System.out.println("MIN!"); XYSeries series = new XYSeries("trend"); for (int n : points) { series.add(n, max); } xy.add(series); } points = new ArrayList(); } } if (points.size() >= window) { XYSeries series = new XYSeries("trend"); for (int n : points) { series.add(n, max); } xy.add(series); } XYSeriesCollection my_data_series = new XYSeriesCollection(); my_data_series.addSeries(data); for (XYSeries x : xy) { my_data_series.addSeries(x); } XYSeries thresh = new XYSeries("threshold"); for (int j = 0; j < d.plots.length; j++) { thresh.add(j, threshold); } my_data_series.addSeries(thresh); //System.out.println(d.name); JFreeChart XYLineChart = ChartFactory.createXYLineChart(d.name, "Position", "Average", my_data_series, PlotOrientation.VERTICAL, true, true, false); bImage1 = (BufferedImage) XYLineChart.createBufferedImage(690, 337); imageIcon = new ImageIcon(bImage1); jLabel1.setIcon(imageIcon); jLabel1.revalidate(); jLabel1.repaint(); jButton1.setText("Save as PNG"); jButton1.repaint(); jButton1.revalidate(); jButton1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new File("Documents")); int retrival = chooser.showSaveDialog(null); if (retrival == JFileChooser.APPROVE_OPTION) { try { ImageIO.write(bImage1, "png", new File(chooser.getSelectedFile() + ".png")); } catch (IOException ex) { System.out.println("Unable to Print!"); } } } }); }
From source file:com.sillelien.dollar.api.types.DollarInfinity.java
@NotNull @Override public Number toNumber() { return positive ? Double.MAX_VALUE : Double.MIN_VALUE; }
From source file:ubic.gemma.core.analysis.preprocess.OutlierDetectionServiceImpl.java
@Override public Collection<OutlierDetails> identifyOutliersByMedianCorrelation(DoubleMatrix<BioAssay, BioAssay> cormat) { List<OutlierDetails> allSamples = new ArrayList<>(); OutlierDetails sample;// w ww . j a va 2 s .c o m /* Find the 1st, 2nd, and 3rd quartiles of each sample */ for (int i = 0; i < cormat.rows(); i++) { DoubleArrayList cors = new DoubleArrayList(); sample = new OutlierDetails(cormat.getRowName(i)); for (int j = 0; j < cormat.columns(); j++) { if (j != i) { // get all sample correlations except correlation with self double d = cormat.get(i, j); cors.add(d); } } assert (cors.size() == cormat.rows() - 1); sample.setFirstQuartile(this.findValueAtDesiredQuantile(cors, 25)); sample.setMedianCorrelation(this.findValueAtDesiredQuantile(cors, 50)); sample.setThirdQuartile(this.findValueAtDesiredQuantile(cors, 75)); if (sample.getFirstQuartile() == Double.MIN_VALUE || sample.getMedianCorrelation() == Double.MIN_VALUE || sample.getThirdQuartile() == Double.MIN_VALUE) { throw new IllegalStateException("Could not determine one or more quartiles for a sample; "); } allSamples.add(sample); } /* Sort all samples by median correlation */ Collections.sort(allSamples, OutlierDetails.MedianComparator); int numOutliers = 0; /* Check for overlap of first quartile and median of consecutive samples */ for (int k = 0; k < allSamples.size() - 1; k++) { // if ( allSamples.get( k ).getMedianCorrelation() < allSamples.get( k + 1 ).getFirstQuartile() ) { if (allSamples.get(k).getThirdQuartile() < allSamples.get(k + 1).getFirstQuartile()) { numOutliers = k + 1; } } List<OutlierDetails> outliers = new ArrayList<>(); for (int m = 0; m < numOutliers; m++) { outliers.add(allSamples.get(m)); } /* * Check that all outliers are legitimate (controls for situations where sorting by median does not give 'true' * order) */ if (numOutliers > 0) { OutlierDetectionServiceImpl.log .info("Removing false positives; number of outliers before test: " + numOutliers); outliers = this.removeFalsePositives(allSamples, outliers, numOutliers); numOutliers = outliers.size(); OutlierDetectionServiceImpl.log .info("Number of outliers after removing false positives: " + numOutliers); } OutlierDetectionServiceImpl.log.info("Found " + numOutliers + " outlier(s)"); return outliers; }
From source file:fiji.plugin.trackmate.action.brownianmotion.WalkerMethodEstimator.java
/** * /*from ww w .ja va2 s.c o m*/ * @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 Framerate in hertz * @param maxdiameter The maximum diameter for the estimation */ public WalkerMethodEstimator(double[][] data, double temp, double visk, double framerate, int maxdiameter) { this.data = data; this.temp = temp; this.visk = visk; this.frameduration = 1 / framerate; minTrackLength = Integer.MAX_VALUE; maxTrackLength = 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 (data[i][0] > msdMax) { msdMax = data[i][0]; } if (this.data[i][1] > maxTrackLength) { maxTrackLength = (int) this.data[i][1]; } if (this.data[i][1] < minTrackLength) { minTrackLength = (int) this.data[i][1]; } //IJ.log("MSD " + this.data[i][0]); } logMapK = new double[maxTrackLength + 1]; logMapGammaK = new double[maxTrackLength + 1]; java.util.Arrays.fill(logMapK, Double.NaN); java.util.Arrays.fill(logMapGammaK, Double.NaN); maxRadiusInNm = maxdiameter / 2.0; 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[maxTrackLength + 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:Statistics.java
public static double maximum(double... vals) { double ret = Double.MIN_VALUE; for (double d : vals) { ret = Math.max(ret, d);/* w ww . j a v a 2s . c o m*/ } return ret; }
From source file:org.primefaces.component.imagecropper.ImageCropperRenderer.java
protected void encodeScript(FacesContext context, ImageCropper cropper) throws IOException { String widgetVar = cropper.resolveWidgetVar(); String clientId = cropper.getClientId(context); String image = clientId + "_image"; String select = null;/*from w ww .java 2 s .c om*/ WidgetBuilder wb = getWidgetBuilder(context); wb.initWithComponentLoad("ImageCropper", widgetVar, clientId, clientId + "_image").attr("image", image); if (cropper.getMinSize() != null) { wb.append(",minSize:[").append(cropper.getMinSize()).append("]"); } if (cropper.getMaxSize() != null) { wb.append(",maxSize:[").append(cropper.getMaxSize()).append("]"); } wb.attr("bgColor", cropper.getBackgroundColor(), null) .attr("bgOpacity", cropper.getBackgroundOpacity(), 0.6) .attr("aspectRatio", cropper.getAspectRatio(), Double.MIN_VALUE) .attr("boxWidth", cropper.getBoxWidth(), 0).attr("boxHeight", cropper.getBoxHeight(), 0); Object value = cropper.getValue(); if (value != null) { CroppedImage croppedImage = (CroppedImage) value; int x = croppedImage.getLeft(); int y = croppedImage.getTop(); int x2 = x + croppedImage.getWidth(); int y2 = y + croppedImage.getHeight(); select = "[" + x + "," + y + "," + x2 + "," + y2 + "]"; } else if (cropper.getInitialCoords() != null) { select = "[" + cropper.getInitialCoords() + "]"; } wb.append(",setSelect:").append(select); wb.finish(); }
From source file:de.biomedical_imaging.ij.nanotrackj.WalkerMethodEstimator.java
/** * /* w w w . ja va2 s . co m*/ * @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:cc.mallet.types.PolyaUrnDirichlet.java
protected long nextPoisson(double meanPoisson) { final double pivot = 40.0d; if (meanPoisson < pivot) { double p = FastMath.exp(-meanPoisson); long n = 0; double r = 1.0d; double rnd = 1.0d; while (n < 1000 * meanPoisson) { rnd = ThreadLocalRandom.current().nextDouble(); r *= rnd;//from w w w. j av a2 s . com if (r >= p) { n++; } else { return n; } } return n; } else { final double lambda = FastMath.floor(meanPoisson); final double lambdaFractional = meanPoisson - lambda; final double logLambda = FastMath.log(lambda); final double logLambdaFactorial = CombinatoricsUtils.factorialLog((int) lambda); final long y2 = lambdaFractional < Double.MIN_VALUE ? 0 : nextPoisson(lambdaFractional); final double delta = FastMath.sqrt(lambda * FastMath.log(32 * lambda / FastMath.PI + 1)); final double halfDelta = delta / 2; final double twolpd = 2 * lambda + delta; final double a1 = FastMath.sqrt(FastMath.PI * twolpd) * FastMath.exp(1 / (8 * lambda)); final double a2 = (twolpd / delta) * FastMath.exp(-delta * (1 + delta) / twolpd); final double aSum = a1 + a2 + 1; final double p1 = a1 / aSum; final double p2 = a2 / aSum; final double c1 = 1 / (8 * lambda); double x = 0; double y = 0; double v = 0; int a = 0; double t = 0; double qr = 0; double qa = 0; for (;;) { final double u = ThreadLocalRandom.current().nextDouble(); if (u <= p1) { final double n = ThreadLocalRandom.current().nextGaussian(); x = n * FastMath.sqrt(lambda + halfDelta) - 0.5d; if (x > delta || x < -lambda) { continue; } y = x < 0 ? FastMath.floor(x) : FastMath.ceil(x); final double e = nextStandardExponential(); v = -e - (n * n / 2) + c1; } else { if (u > p1 + p2) { y = lambda; break; } else { x = delta + (twolpd / delta) * nextStandardExponential(); y = FastMath.ceil(x); v = -nextStandardExponential() - delta * (x + 1) / twolpd; } } a = x < 0 ? 1 : 0; t = y * (y + 1) / (2 * lambda); if (v < -t && a == 0) { y = lambda + y; break; } qr = t * ((2 * y + 1) / (6 * lambda) - 1); qa = qr - (t * t) / (3 * (lambda + a * (y + 1))); if (v < qa) { y = lambda + y; break; } if (v > qr) { continue; } if (v < y * logLambda - CombinatoricsUtils.factorialLog((int) (y + lambda)) + logLambdaFactorial) { y = lambda + y; break; } } return y2 + (long) y; } }
From source file:springfox.bean.validators.plugins.MinMaxAnnotationPlugin.java
private AllowableValues createAllowableValuesFromMinMaxForNumbers(Optional<Min> min, Optional<Max> max) { AllowableRangeValues myvalues = null; if (min.isPresent() && max.isPresent()) { LOG.debug("@Min+@Max detected: adding AllowableRangeValues to field "); myvalues = new AllowableRangeValues(Double.toString(min.get().value()), Double.toString(max.get().value())); } else if (min.isPresent()) { LOG.debug("@Min detected: adding AllowableRangeValues to field "); // use Max value until "infinity" works myvalues = new AllowableRangeValues(Double.toString(min.get().value()), Double.toString(Double.MAX_VALUE)); } else if (max.isPresent()) { // use Min value until "infinity" works LOG.debug("@Max detected: adding AllowableRangeValues to field "); myvalues = new AllowableRangeValues(Double.toString(Double.MIN_VALUE), Double.toString(max.get().value())); }/*ww w . ja v a 2 s . c om*/ return myvalues; }