List of usage examples for java.lang Double NEGATIVE_INFINITY
double NEGATIVE_INFINITY
To view the source code for java.lang Double NEGATIVE_INFINITY.
Click Source Link
From source file:eu.cassandra.utils.Utils.java
/** * This function is used for the detection of rising points preceding a * reduction point, so that there is a possibility they can be connected as a * pair/* w w w.j a va2s . c o m*/ * * @param index * The index of the reduction point of interest. * @param pois * The list of points of interest under examination. * @return an array of indices that contain possible combinatorial rising * points of interest. */ public static Integer[] findRisPoints(int index, ArrayList<PointOfInterest> pois) { ArrayList<Integer> temp = new ArrayList<Integer>(); double limit = -pairingLimit(pois.get(index).getPDiff()); double timeLimit = Double.NEGATIVE_INFINITY; if (Constants.SIMPLE_TIME_COMPLEXITY == true) timeLimit = pois.get(index).getMinute() - Constants.TEMPORAL_THRESHOLD; for (int i = 0; i < index; i++) if (pois.get(i).getRising() && pois.get(i).getMinute() >= timeLimit && limit > pois.get(i).getPDiff()) temp.add(i); Integer[] result = new Integer[temp.size()]; for (int i = 0; i < temp.size(); i++) result[i] = temp.get(i); return result; }
From source file:clus.heuristic.FTest.java
public static double calcVarianceReductionHeuristic(double n_tot, double ss_tot, double ss_sum) { double value = ss_tot - ss_sum; if (value < MathUtil.C1E_9) { // Gain too small return Double.NEGATIVE_INFINITY; }//from w w w . ja va2 s. com if (Settings.FTEST_LEVEL == 0) { // No F-test -> just return value return value; } int n_2 = (int) Math.floor(n_tot - 2.0 + 0.5); if (n_2 <= 0) { return Double.NEGATIVE_INFINITY; } else { if (FTest.ftest(Settings.FTEST_LEVEL, ss_tot, ss_sum, n_2)) { return value; } else { return Double.NEGATIVE_INFINITY; } } }
From source file:maltcms.ui.fileHandles.csv.CSV2JFCLoader.java
@Override public void run() { CSV2TableLoader tl = new CSV2TableLoader(this.ph, this.is); DefaultTableModel dtm;//from w w w . j a v a 2 s . c o m try { dtm = tl.call(); if (this.mode == CHART.XY) { XYSeriesCollection cd = new XYSeriesCollection(); for (int j = 0; j < dtm.getColumnCount(); j++) { XYSeries xys = new XYSeries(dtm.getColumnName(j)); for (int i = 0; i < dtm.getRowCount(); i++) { Object o = dtm.getValueAt(i, j); try { double d = Double.parseDouble(o.toString()); xys.add(i, d); Logger.getLogger(getClass().getName()).log(Level.INFO, "Adding {0} {1} {2}", new Object[] { i, d, dtm.getColumnName(j) }); } catch (Exception e) { } } cd.addSeries(xys); } XYLineAndShapeRenderer d = new XYLineAndShapeRenderer(true, false); XYPlot xyp = new XYPlot(cd, new NumberAxis("category"), new NumberAxis("value"), d); JFreeChart jfc = new JFreeChart(this.title, xyp); jtc.setChart(jfc); Logger.getLogger(getClass().getName()).info("creating chart done"); } else if (this.mode == CHART.MATRIX) { DefaultXYZDataset cd = new DefaultXYZDataset(); Logger.getLogger(getClass().getName()).log(Level.INFO, "Name of column 0: {0}", dtm.getColumnName(0)); if (dtm.getColumnName(0).isEmpty()) { Logger.getLogger(getClass().getName()).info("Removing column 0"); dtm = removeColumn(dtm, 0); } if (dtm.getColumnName(dtm.getColumnCount() - 1).equalsIgnoreCase("filename")) { dtm = removeColumn(dtm, dtm.getColumnCount() - 1); } StringBuilder sb = new StringBuilder(); for (int i = 0; i < dtm.getRowCount(); i++) { for (int j = 0; j < dtm.getColumnCount(); j++) { sb.append(dtm.getValueAt(i, j) + " "); } sb.append("\n"); } Logger.getLogger(getClass().getName()).log(Level.INFO, "Table before sorting: {0}", sb.toString()); // dtm = sort(dtm); StringBuilder sb2 = new StringBuilder(); for (int i = 0; i < dtm.getRowCount(); i++) { for (int j = 0; j < dtm.getColumnCount(); j++) { sb2.append(dtm.getValueAt(i, j) + " "); } sb2.append("\n"); } Logger.getLogger(getClass().getName()).log(Level.INFO, "Table after sorting: {0}", sb2.toString()); int rows = dtm.getRowCount(); int columns = dtm.getColumnCount(); Logger.getLogger(getClass().getName()).log(Level.INFO, "Storing {0} * {1} elements, {2} total!", new Object[] { columns, rows, rows * columns }); double[][] data = new double[3][(columns * rows)]; ArrayDouble.D1 dt = new ArrayDouble.D1((columns) * rows); double min = Double.POSITIVE_INFINITY; double max = Double.NEGATIVE_INFINITY; EvalTools.eqI(rows, columns, this); int k = 0; for (int i = 0; i < dtm.getRowCount(); i++) { for (int j = 0; j < dtm.getColumnCount(); j++) { Object o = dtm.getValueAt(i, j); try { double d = Double.parseDouble(o.toString()); if (d < min) { min = d; } if (d > max) { max = d; } data[0][k] = (double) i; data[1][k] = (double) j; data[2][k] = d; dt.set(k, d); k++; //System.out.println("Adding "+i+" "+d+" "+dtm.getColumnName(j)); } catch (Exception e) { } } //cd.addSeries(xys); } cd.addSeries(this.title, data); XYBlockRenderer xyb = new XYBlockRenderer(); GradientPaintScale ps = new GradientPaintScale(ImageTools.createSampleTable(256), min, max, ImageTools .rampToColorArray(new ColorRampReader().readColorRamp("res/colorRamps/bcgyr.csv"))); xyb.setPaintScale(ps); final String[] colnames = new String[dtm.getColumnCount()]; for (int i = 0; i < colnames.length; i++) { colnames[i] = dtm.getColumnName(i); } NumberAxis na1 = new SymbolAxis("category", colnames); na1.setVerticalTickLabels(false); NumberAxis na2 = new SymbolAxis("category", colnames); na1.setVerticalTickLabels(true); XYPlot xyp = new XYPlot(cd, na1, na2, xyb); xyb.setSeriesToolTipGenerator(0, new XYToolTipGenerator() { @Override public String generateToolTip(XYDataset xyd, int i, int i1) { return "[" + colnames[xyd.getX(i, i1).intValue()] + ":" + colnames[xyd.getY(i, i1).intValue()] + "] = " + ((XYZDataset) xyd).getZValue(i, i1) + ""; } }); JFreeChart jfc = new JFreeChart(this.title, xyp); NumberAxis values = new NumberAxis("value"); values.setAutoRange(false); values.setRangeWithMargins(min, max); PaintScaleLegend psl = new PaintScaleLegend(ps, values); psl.setBackgroundPaint(jfc.getBackgroundPaint()); jfc.addSubtitle(psl); psl.setStripWidth(50); psl.setPadding(20, 20, 20, 20); psl.setHeight(200); psl.setPosition(RectangleEdge.RIGHT); jtc.setChart(jfc); } } catch (Exception ex) { Exceptions.printStackTrace(ex); } ph.finish(); }
From source file:gmc_hdfs.distribution.ParetoDistribution.java
/** {@inheritDoc} * * See documentation of {@link #density(double)} for computation details. *///from ww w . j av a 2 s . c om @Override public double logDensity(double x) { if (x < scale) { return Double.NEGATIVE_INFINITY; } return FastMath.log(scale) * shape - FastMath.log(x) * (shape + 1) + FastMath.log(shape); }
From source file:com.cinnober.msgcodec.json.JsonValueHandlerTest.java
@Test public void testFloat64EncodeNegInfinity() throws IOException { StringWriter out = new StringWriter(); JsonGenerator g = f.createGenerator(out); JsonValueHandler.FLOAT64.writeValue(Double.NEGATIVE_INFINITY, g); g.flush();//from www . j av a 2 s . c o m assertEquals("\"-Infinity\"", out.toString()); }
From source file:ch.epfl.leb.sass.models.fluorophores.commands.internal.FluorophoreReceiverIT.java
/** * Test of generateFluorophoresGrid2D method, of class FluorophoreReceiver. */// w ww . ja v a 2 s . co m @Test public void testGenerateFluorophoresGrid2D() { GenerateFluorophoresGrid2D.Builder fluorBuilder = new GenerateFluorophoresGrid2D.Builder(); fluorBuilder.spacing(4); // spacing in pixels // Create the set of fluorophores. fluorBuilder.camera(camera).psfBuilder(psfBuilder).fluorDynamics(fluorDynamics).illumination(illumination); FluorophoreCommand fluorCommand = fluorBuilder.build(); List<Fluorophore> fluorophores = fluorCommand.generateFluorophores(); assertEquals(49, fluorophores.size()); double minX = Double.POSITIVE_INFINITY; double maxX = Double.NEGATIVE_INFINITY; double minY = Double.POSITIVE_INFINITY; double maxY = Double.NEGATIVE_INFINITY; for (Fluorophore f : fluorophores) { if (f.getX() < minX) minX = f.getX(); if (f.getX() > maxX) maxX = f.getX(); if (f.getY() < minY) minY = f.getY(); if (f.getY() > maxY) maxY = f.getY(); } assertEquals(28.0, maxX, 0.0); assertEquals(4.0, minX, 0.0); assertEquals(28.0, maxY, 0.0); assertEquals(4.0, minY, 0.0); }
From source file:com.opengamma.analytics.financial.model.volatility.BlackScholesFormulaRepository.java
/** * The spot delta//from ww w. j a va 2 s.c om * @param spot The spot value of the underlying * @param strike The Strike * @param timeToExpiry The time-to-expiry * @param lognormalVol The log-normal volatility * @param interestRate The interest rate * @param costOfCarry The cost-of-carry rate * @param isCall true for call * @return The spot delta */ @ExternalFunction public static double delta(final double spot, final double strike, final double timeToExpiry, final double lognormalVol, final double interestRate, final double costOfCarry, final boolean isCall) { ArgumentChecker.isTrue(spot >= 0.0, "negative/NaN spot; have {}", spot); ArgumentChecker.isTrue(strike >= 0.0, "negative/NaN strike; have {}", strike); ArgumentChecker.isTrue(timeToExpiry >= 0.0, "negative/NaN timeToExpiry; have {}", timeToExpiry); ArgumentChecker.isTrue(lognormalVol >= 0.0, "negative/NaN lognormalVol; have {}", lognormalVol); ArgumentChecker.isFalse(Double.isNaN(interestRate), "interestRate is NaN"); ArgumentChecker.isFalse(Double.isNaN(costOfCarry), "costOfCarry is NaN"); double coef = 0.; if ((interestRate > LARGE && costOfCarry > LARGE) || (-interestRate > LARGE && -costOfCarry > LARGE) || Math.abs(costOfCarry - interestRate) < SMALL) { coef = 1.; //ref value is returned } else { final double rate = costOfCarry - interestRate; if (rate > LARGE) { return isCall ? Double.POSITIVE_INFINITY : (costOfCarry > LARGE ? 0. : Double.NEGATIVE_INFINITY); } if (-rate > LARGE) { return 0.; } coef = Math.exp(rate * timeToExpiry); } if (spot > LARGE * strike) { return isCall ? coef : 0.; } if (spot < SMALL * strike) { return isCall ? 0. : -coef; } final int sign = isCall ? 1 : -1; final double rootT = Math.sqrt(timeToExpiry); double sigmaRootT = lognormalVol * rootT; if (Double.isNaN(sigmaRootT)) { sigmaRootT = 1.; //ref value is returned } double factor = Math.exp(costOfCarry * timeToExpiry); if (Double.isNaN(factor)) { factor = 1.; //ref value is returned } double rescaledSpot = spot * factor; double d1 = 0.; if (Math.abs(spot - strike) < SMALL || sigmaRootT > LARGE || (spot > LARGE && strike > LARGE)) { final double coefD1 = (costOfCarry / lognormalVol + 0.5 * lognormalVol); final double tmp = coefD1 * rootT; d1 = Double.isNaN(tmp) ? 0. : tmp; } else { if (sigmaRootT < SMALL) { return isCall ? (rescaledSpot > strike ? coef : 0.) : (rescaledSpot < strike ? -coef : 0.); } final double tmp = costOfCarry * rootT / lognormalVol; final double sig = (costOfCarry >= 0.) ? 1. : -1.; final double scnd = Double.isNaN(tmp) ? ((lognormalVol < LARGE && lognormalVol > SMALL) ? sig / lognormalVol : sig * rootT) : tmp; d1 = Math.log(spot / strike) / sigmaRootT + scnd + 0.5 * sigmaRootT; } // if (Double.isNaN(d1)) { // throw new IllegalArgumentException("NaN found"); // } final double norm = NORMAL.getCDF(sign * d1); return norm < SMALL ? 0. : sign * coef * norm; }
From source file:ec.ui.view.res.ResidualsView.java
private Range calcRange(double[] values) { double min = Double.NEGATIVE_INFINITY, max = -Double.POSITIVE_INFINITY; DescriptiveStatistics stats = new DescriptiveStatistics(new DataBlock(values)); double smin = stats.getMin(), smax = stats.getMax(); if (Double.isInfinite(min) || smin < min) { min = smin;/*from ww w . j a va 2 s .c o m*/ } if (Double.isInfinite(max) || smax > max) { max = smax; } if (Double.isInfinite(max) || Double.isInfinite(min)) { return new Range(0, 1); } double length = max - min; if (length == 0) { return new Range(0, 1); } else { //double eps = length * .05; //return new Range(min - eps, max + eps); return new Range(min, max); } }
From source file:com.moilioncircle.redis.replicator.rdb.AbstractRdbParser.java
protected double rdbLoadDoubleValue() throws IOException { int len = in.read(); switch (len) { case 255:/*from w ww .j a v a 2 s . c om*/ return Double.NEGATIVE_INFINITY; case 254: return Double.POSITIVE_INFINITY; case 253: return Double.NaN; default: byte[] bytes = in.readBytes(len); return Double.valueOf(new String(bytes)); } }
From source file:com.act.lcms.db.io.report.IonAnalysisInterchangeModel.java
/** * This function is used to compute log frequency distribution of the ion model vs a metric. * @param metric The metric on which the frequency distribution is plotted * @return A map of a range to the count of molecules that get bucketed in that range *//*from w w w.java 2 s .c om*/ public Map<Pair<Double, Double>, Integer> computeLogFrequencyDistributionOfMoleculeCountToMetric( METRIC metric) { Map<Pair<Double, Double>, Integer> rangeToHitCount = new HashMap<>(); // This variable represents the total number of statistics that have zero values. Integer countOfZeroStats = 0; // This statistic represents the log value of the min statistic. Double minLogValue = Double.MAX_VALUE; for (ResultForMZ resultForMZ : this.getResults()) { for (HitOrMiss molecule : resultForMZ.getMolecules()) { Double power = 0.0; switch (metric) { case TIME: power = Math.log10(molecule.getTime()); break; case INTENSITY: power = Math.log10(molecule.getIntensity()); break; case SNR: power = Math.log10(molecule.getSnr()); break; } if (power.equals(Double.NEGATIVE_INFINITY)) { // We know the statistic was 0 here. countOfZeroStats++; break; } Double floor = Math.floor(power); Double lowerBound = Math.pow(10.0, floor); Double upperBound = Math.pow(10.0, floor + 1); minLogValue = Math.min(minLogValue, lowerBound); Pair<Double, Double> key = Pair.of(lowerBound, upperBound); rangeToHitCount.compute(key, (k, v) -> (v == null) ? 1 : v + 1); } // We count the total number of zero statistics and put them in the 0 to minLog metric bucket. if (countOfZeroStats > 0) { Pair<Double, Double> key = Pair.of(0.0, minLogValue); rangeToHitCount.put(key, countOfZeroStats); } } return rangeToHitCount; }