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:org.spf4j.perf.impl.chart.QuantizedXYZDatasetImpl.java
public QuantizedXYZDatasetImpl(final String[] dataSources, final double[][] pdata, final long startTimeMillis, final long step) { this.data = pdata.clone(); this.startTimeMillis = startTimeMillis; this.stepMillis = step; quantas = new ArrayList<ComparablePair<Quanta, Integer>>(dataSources.length); for (int i = 0; i < dataSources.length; i++) { String ds = dataSources[i]; if (ds.startsWith("Q")) { Quanta quanta = new Quanta(ds); quantas.add(ComparablePair.of(quanta, i)); }//from w w w . j av a 2s . co m } Collections.sort(quantas); final int nrQuantas = quantas.size(); int seriesSize = nrQuantas * data.length; x = new double[seriesSize]; y = new double[seriesSize]; z = new double[seriesSize]; double lMinValue = Double.POSITIVE_INFINITY; double lMaxValue = Double.NEGATIVE_INFINITY; int k = 0; for (int j = 0; j < nrQuantas; j++) { ComparablePair<Quanta, Integer> pair = quantas.get(j); double[] values = Arrays.getColumn(data, pair.getSecond()); for (int i = 0; i < values.length; i++) { x[k] = i; //timestamps[i]*1000; y[k] = j; //(double) pair.getFirst().getClosestToZero(); double zval = values[i]; z[k] = zval; if (zval > lMaxValue) { lMaxValue = zval; } if (zval < lMinValue) { lMinValue = zval; } k++; } } this.minValue = lMinValue; this.maxValue = lMaxValue; }
From source file:com.streamsets.pipeline.stage.it.AvroToParquetHiveIT.java
@Parameterized.Parameters(name = "type({0})") public static Collection<Object[]> data() throws Exception { return Arrays.asList(new Object[][] { // Primitive types { "\"boolean\"", true, true, "BOOLEAN", Types.BOOLEAN, "0" }, { "\"int\"", Integer.MIN_VALUE, Integer.MIN_VALUE, "INT", Types.INTEGER, "0" }, { "\"long\"", Long.MAX_VALUE, Long.MAX_VALUE, "BIGINT", Types.BIGINT, "0" }, // From some reason type is FLOAT, but returned object is double { "\"float\"", Float.NaN, Double.NaN, "FLOAT", Types.FLOAT, "0" }, { "\"double\"", Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, "DOUBLE", Types.DOUBLE, "0" }, { "\"bytes\"", ByteBuffer.wrap(new byte[] { (byte) 0x00, (byte) 0xFF }), new byte[] { (byte) 0x00, (byte) 0xFF }, "BINARY", Types.BINARY, "1.0" }, { "\"string\"", new Utf8("StreamSets"), "StreamSets", "STRING", Types.VARCHAR, "1.0" }, // Complex types are skipped for now // Logical types { DECIMAL.toString(), ByteBuffer.wrap(new byte[] { (byte) 0x0F }), new BigDecimal("2"), "DECIMAL", Types.DECIMAL, "0" }, { DATE.toString(), 17039, new java.sql.Date(116, 7, 26), "DATE", Types.DATE, "1.2" }, }); }
From source file:dr.math.distributions.NegativeBinomialDistribution.java
public static double logPdf(double x, double mean, double alpha) { if (x < 0) return Double.NEGATIVE_INFINITY; // double r = -1 * (mean*mean) / (mean - stdev*stdev); // double p = mean / (stdev*stdev); // return Math.log(Math.pow(1-p,x)) + Math.log(Math.pow(p, r)) + GammaFunction.lnGamma(r+x) - GammaFunction.lnGamma(r) - GammaFunction.lnGamma(x+1); double theta = 1.0 / alpha; double p = theta / (theta + mean); return Math.log(1 - p) * x + Math.log(p) * theta + GammaFunction.lnGamma(theta + x) - GammaFunction.lnGamma(theta) - GammaFunction.lnGamma(x + 1); }
From source file:mase.stat.CompetitiveBestStat.java
@Override public void postEvaluationStatistics(EvolutionState state) { super.postInitializationStatistics(state); for (int i = 0; i < state.population.subpops.length; i++) { Individual best = null;/*from w ww . j a v a2 s . c om*/ int index = -1; double bestFitness = Double.NEGATIVE_INFINITY; for (int j = 0; j < state.population.subpops[i].individuals.length; j++) { Individual ind = state.population.subpops[i].individuals[j]; double fit = ((ExpandedFitness) ind.fitness).getFitnessScore(); if (fit > bestFitness) { bestFitness = fit; best = ind; index = j; } } PersistentSolution c = SolutionPersistence.createPersistentController(state, best, i, index); try { if (compress) { SolutionPersistence.writeSolutionToTar(c, taos[i]); } else { SolutionPersistence.writeSolutionInFolder(c, outFile[i]); } if (last != null) { SolutionPersistence.writeSolution(c, last[i]); } } catch (Exception e) { e.printStackTrace(); } } }
From source file:mase.evorbc.KdTreeRepertoire.java
@Override public void load(File repo, File coordinates) throws IOException { repFile = repo;//from w w w .j ava 2 s. c o m repFileHash = FileUtils.checksumCRC32(repFile); if (coordinates != null) { coordsFile = coordinates; coordsFileHash = FileUtils.checksumCRC32(coordsFile); } List<PersistentSolution> solutions; try { solutions = SolutionPersistence.readSolutionsFromTar(repo); } catch (Exception ex) { Logger.getLogger(ArbitratorFactory.class.getName()).log(Level.SEVERE, null, ex); return; } Map<Integer, double[]> coords = null; if (coordinates != null) { coords = fileCoordinates(coordinates); if (coords.size() != solutions.size()) { throw new IOException("Number of solutions in repertoire does not match number of coordinates"); } } else { coords = encodedCoordinates(solutions); } int n = coords.get(solutions.get(0).getIndex()).length; bounds = new Pair[n]; for (int i = 0; i < n; i++) { double min = Double.POSITIVE_INFINITY; double max = Double.NEGATIVE_INFINITY; for (double[] c : coords.values()) { min = Math.min(min, c[i]); max = Math.max(max, c[i]); } bounds[i] = Pair.of(min, max); } tree = new KdTree.Euclidean<>(n); for (int i = 0; i < solutions.size(); i++) { PersistentSolution sol = solutions.get(i); AgentController ac = sol.getController().getAgentControllers(1)[0]; double[] c = coords.get(sol.getIndex()); if (c == null) { throw new IOException("Coordinate not found for index " + sol.getIndex()); } tree.addPoint(c, ac); } }
From source file:statistic.graph.gui.Charts.java
private static void initXAxis(XYPlot plot, XYDataset dataset) { plot.setDomainAxis(new NumberAxis(plot.getDomainAxis().getLabel())); XYSeriesCollection collection = (XYSeriesCollection) dataset; double max = Double.NEGATIVE_INFINITY; double min = Double.POSITIVE_INFINITY; if (collection != null) { for (int s = 0; s < collection.getSeriesCount(); s++) { for (int d = 0; d < collection.getItemCount(s); d++) { XYDataItem data = collection.getSeries(s).getDataItem(d); if (data.getX().longValue() == Integer.MAX_VALUE || data.getX().longValue() == Integer.MIN_VALUE) { continue; }/* w w w . ja v a 2 s . c o m*/ if (data.getX().doubleValue() > max) { max = data.getX().doubleValue(); } if (data.getX().doubleValue() < min) { min = data.getX().doubleValue(); } } } if (min < max) { plot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); plot.getDomainAxis().setRange(min - 0.5, max + 0.5); for (int s = 0; s < collection.getSeriesCount(); s++) { XYSeries series = collection.getSeries(s); if (series.indexOf(Integer.MIN_VALUE) >= 0) { XYDataItem item = series.remove((Number) Integer.MIN_VALUE); if (series.indexOf(min) < 0) { series.add(min, item.getY()); } } if (series.indexOf(Integer.MAX_VALUE) >= 0) { XYDataItem item = series.remove((Number) Integer.MAX_VALUE); if (series.indexOf(max) < 0) { series.add(max, item.getY()); } } } } else { plot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); plot.getDomainAxis().setRange(0 - 0.5, 1 + 0.5); } } else { plot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); plot.getDomainAxis().setRange(0 - 0.5, 1 + 0.5); } }
From source file:zipkin.autoconfigure.metrics.PrometheusMetricsAutoConfiguration.java
private String prometheusDouble(double value) { if (value == Double.POSITIVE_INFINITY) { return "+Inf"; } else if (value == Double.NEGATIVE_INFINITY) { return "-Inf"; } else {// w w w . j a va 2s .c o m return String.valueOf(value); } }
From source file:it.unibo.alchemist.model.implementations.linkingrules.ConnectionBeam.java
@Override public Neighborhood<T> computeNeighborhood(final Node<T> center, final Environment<T> env) { final Neighborhood<T> normal = super.computeNeighborhood(center, env); if (oenv == null) { if (!(env instanceof Environment2DWithObstacles<?, ?>)) { return normal; }//from w w w . j av a 2s.com oenv = (Environment2DWithObstacles<?, ?>) env; obstacles.reset(); oenv.getObstacles().forEach((obs) -> { /* * Doubles are prone to approximation errors. Use nextAfter to get rid of them */ final Rectangle2D bounds = obs.getBounds2D(); final double mx = nextAfter(bounds.getMinX(), java.lang.Double.NEGATIVE_INFINITY); final double my = nextAfter(bounds.getMinY(), java.lang.Double.NEGATIVE_INFINITY); final double ex = nextUp(bounds.getMaxX()); final double ey = nextUp(bounds.getMaxY()); obstacles.add(new Area(new Rectangle2D.Double(mx, my, ex - mx, ey - my))); }); } if (!normal.isEmpty()) { final Position cp = env.getPosition(center); final List<Node<T>> neighs = normal.getNeighbors().stream().filter((neigh) -> { final Position np = env.getPosition(neigh); return !oenv.intersectsObstacle(cp, np) || projectedBeamOvercomesObstacle(cp, np); }).collect(ArrayList::new, (l, el) -> l.add(el), (l1, l2) -> l1.addAll(l2)); return Neighborhoods.make(env, center, neighs); } return normal; }
From source file:it.unibo.alchemist.boundary.monitors.EnvironmentInspector.java
@Override public void finished(final Environment<T> env, final Time time, final long step) { if (writer != null) { writer.close();/*from w ww. j av a 2 s . com*/ } writer = null; lastUpdate = Double.NEGATIVE_INFINITY; lastStep = Long.MIN_VALUE; fpCache = null; }
From source file:com.github.kutschkem.Qgen.QuestionRankerByParseProbability.java
private Double average(List<ScoredObject<Tree>> kBestPCFGParses) { double result = 0; int norm = 0; for (ScoredObject<Tree> s : kBestPCFGParses) { if (s.object().firstChild().label().value().equals("SBARQ")) { result += s.score();/* w ww . j ava 2s . c om*/ norm++; } } if (result == 0) return Double.NEGATIVE_INFINITY; return result / norm; }