List of usage examples for java.lang Double NaN
double NaN
To view the source code for java.lang Double NaN.
Click Source Link
From source file:mop.MemoryLogger.java
/** * Registers the memory consumption every 100 events. Flag MEMORY_LOGGING has to be activated. *///from w w w .jav a 2 s .c o m public void logMemoryConsumption() { if (STATS_LOGGING && timestamp++ % 100 == 0) { double memoryConsumption = (((double) (Runtime.getRuntime().totalMemory() / 1024) / 1024) - ((double) (Runtime.getRuntime().freeMemory() / 1024) / 1024)); // filter NaNs if (memoryConsumption != Double.NaN) { memStats.addValue(memoryConsumption); } else { NaNcount++; } } }
From source file:at.alladin.rmbt.controlServer.ResultUpdateResource.java
@Post("json") public String request(final String entity) { addAllowOrigin();// www . jav a 2s . c o m JSONObject request = null; final ErrorList errorList = new ErrorList(); final JSONObject answer = new JSONObject(); final String ip = getIP(); System.out.println(MessageFormat.format(labels.getString("NEW_RESULT_UPDATE"), ip)); if (entity != null && !entity.isEmpty()) { try { request = new JSONObject(entity); final UUID clientUUID = UUID.fromString(request.getString("uuid")); final UUID testUUID = UUID.fromString(request.getString("test_uuid")); final int zipCode = request.optInt("zip_code", 0); final double geoLat = request.optDouble("geo_lat", Double.NaN); final double geoLong = request.optDouble("geo_long", Double.NaN); final float geoAccuracy = (float) request.optDouble("accuracy", 0); final String provider = request.optString("provider").toLowerCase(); final Client client = new Client(conn); final long clientId = client.getClientByUuid(clientUUID); if (clientId < 0) throw new IllegalArgumentException("error while loading client"); final Test test = new Test(conn); if (test.getTestByUuid(testUUID) < 0) throw new IllegalArgumentException("error while loading test"); if (test.getField("client_id").longValue() != clientId) throw new IllegalArgumentException("client UUID does not match test"); if (zipCode > 0) { ((IntField) test.getField("zip_code")).setValue(zipCode); } if (!Double.isNaN(geoLat) && !Double.isNaN(geoLong) && (provider.equals(GEO_PROVIDER_GEOCODER) || provider.equals(GEO_PROVIDER_MANUAL))) { final GeoLocation geoloc = new GeoLocation(conn); geoloc.setTest_id(test.getUid()); final Timestamp tstamp = java.sql.Timestamp .valueOf(new Timestamp((new Date().getTime())).toString()); geoloc.setTime(tstamp, TimeZone.getDefault().toString()); geoloc.setAccuracy(geoAccuracy); geoloc.setGeo_lat(geoLat); geoloc.setGeo_long(geoLong); geoloc.setProvider(provider); geoloc.storeLocation(); ((DoubleField) test.getField("geo_lat")).setValue(geoLat); ((DoubleField) test.getField("geo_long")).setValue(geoLong); ((DoubleField) test.getField("geo_accuracy")).setValue(geoAccuracy); test.getField("geo_provider").setString(provider); } test.storeTestResults(true); if (test.hasError()) errorList.addError(test.getError()); } catch (final JSONException e) { errorList.addError("ERROR_REQUEST_JSON"); System.out.println("Error parsing JSDON Data " + e.toString()); } catch (final IllegalArgumentException e) { errorList.addError("ERROR_REQUEST_JSON"); System.out.println("Error parsing JSDON Data " + e.toString()); } } return answer.toString(); }
From source file:org.jfree.data.statistics.SimpleHistogramBinTest.java
/** * Some checks for the accepts() method. *//*from w ww . jav a 2s . c om*/ @Test public void testAccepts() { SimpleHistogramBin bin1 = new SimpleHistogramBin(1.0, 2.0); assertFalse(bin1.accepts(0.0)); assertTrue(bin1.accepts(1.0)); assertTrue(bin1.accepts(1.5)); assertTrue(bin1.accepts(2.0)); assertFalse(bin1.accepts(2.1)); assertFalse(bin1.accepts(Double.NaN)); SimpleHistogramBin bin2 = new SimpleHistogramBin(1.0, 2.0, false, false); assertFalse(bin2.accepts(0.0)); assertFalse(bin2.accepts(1.0)); assertTrue(bin2.accepts(1.5)); assertFalse(bin2.accepts(2.0)); assertFalse(bin2.accepts(2.1)); assertFalse(bin2.accepts(Double.NaN)); }
From source file:eagle.log.entity.EntityQualifierUtils.java
public static Map<String, Double> keyValuesToDoubleMap(List<KeyValue> row, EntityDefinition ed) { Map<String, Double> result = new HashMap<String, Double>(); for (KeyValue kv : row) { String qualifierName = new String(kv.getQualifier()); if (!ed.isTag(qualifierName)) { Qualifier qualifier = ed.getDisplayNameMap().get(qualifierName); if (qualifier == null) { qualifier = ed.getQualifierNameMap().get(qualifierName); }//w ww. j a v a 2 s.c o m qualifierName = qualifier.getDisplayName(); Object value = qualifier.getSerDeser().deserialize(kv.getValue()); result.put(qualifierName, convertObjToDouble(value)); } else { result.put(qualifierName, Double.NaN); } } return result; }
From source file:it.unibo.alchemist.model.implementations.timedistributions.SAPEREExponentialTime.java
/** * @param rateEquation/*www . java 2 s. com*/ * the rate equation * @param start * initial time * @param random * the {@link RandomGenerator} */ public SAPEREExponentialTime(final String rateEquation, final Time start, final RandomGenerator random) { super(Double.NaN, start, Objects.requireNonNull(random)); double temp = 0d; boolean numeric = true; try { temp = Double.parseDouble(Objects.requireNonNull(rateEquation)); } catch (NumberFormatException e) { numeric = false; } numericRate = numeric; staticRate = temp; if (numericRate) { if (Double.isInfinite(staticRate)) { exp = new Expression("asap"); } else { exp = new Expression(FORMAT.format(staticRate)); } } else { exp = new Expression(rateEquation); } }
From source file:de.biomedical_imaging.traJ.features.SplineCurveSpatialFeature.java
@Override /**/* w w w.j av a2s. com*/ * @return [0] Mean distance [1] SD distance */ public double[] evaluate() { splinefit = new TrajectorySplineFit(t, nSegments); splinefit.calculateSpline(); if (!splinefit.wasSuccessfull()) { return new double[] { Double.NaN, Double.NaN }; } double[] data = new double[t.size()]; for (int i = 0; i < t.size(); i++) { Point2D.Double help = new Point2D.Double(splinefit.getRotatedTrajectory().get(i).x, splinefit.getRotatedTrajectory().get(i).y); data[i] = help.distance(splinefit.minDistancePointSpline(new Point2D.Double( splinefit.getRotatedTrajectory().get(i).x, splinefit.getRotatedTrajectory().get(i).y), 50)); } Mean m = new Mean(); StandardDeviation sd = new StandardDeviation(); result = new double[] { m.evaluate(data), sd.evaluate(data) }; return result; }
From source file:com.zatarox.chess.skychess.tables.TranspositionTable.java
/** * Returns the upperbound for the current board. * * @param position/* w w w.j av a 2s.co m*/ * @return */ public synchronized double getUpperbound(Board position) { double result = Double.NaN; if (getTable().containsKey(position)) { result = ((Entry) getTable().get(position)).upperbound; } return result; }
From source file:org.geppetto.simulation.CustomSerializer.java
@Override public void serialize(Double value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { if (null == value) { // write the word 'null' if there's no value available jgen.writeNull();/*from ww w .j av a 2s . c o m*/ } else if (value.equals(Double.NaN)) { jgen.writeNumber(Double.NaN); } else { final String pattern = "#.##"; final DecimalFormat myFormatter = new DecimalFormat(pattern); final String output = myFormatter.format(value).replace(",", "."); jgen.writeNumber(output); } }
From source file:com.bmwcarit.barefoot.matcher.MatcherSample.java
/** * Creates a {@link MatcherSample} object with an identifier, measured position and time of * measurement.//from w ww. jav a2 s . c o m * * @param id Identifier of sample. * @param time Time of measurement in milliseconds epoch time. * @param point Point of measured position. */ public MatcherSample(String id, long time, Point point) { this(id, time, point, Double.NaN); }
From source file:mt.LengthDistribution.java
public static void GetLengthDistributionArray(ArrayList<File> AllMovies, double[] calibration) { ArrayList<Double> maxlist = new ArrayList<Double>(); for (int i = 0; i < AllMovies.size(); ++i) { double maxlength = LengthDistribution.Lengthdistro(AllMovies.get(i)); if (maxlength != Double.NaN && maxlength > 0) maxlist.add(maxlength);//from ww w . j av a 2 s .c om } Collections.sort(maxlist); int min = 0; int max = (int) Math.round(maxlist.get(maxlist.size() - 1)) + 1; XYSeries counterseries = new XYSeries("MT length distribution"); XYSeries Logcounterseries = new XYSeries("MT Log length distribution"); final ArrayList<Point> points = new ArrayList<Point>(); for (int length = 0; length < max; ++length) { HashMap<Integer, Integer> frameseed = new HashMap<Integer, Integer>(); int count = 0; for (int i = 0; i < AllMovies.size(); ++i) { File file = AllMovies.get(i); double currentlength = LengthDistribution.Lengthdistro(file); ArrayList<FLSobject> currentobject = Tracking.loadMTStat(file); if (currentlength > length) { for (int index = 0; index < currentobject.size(); ++index) { ArrayList<Integer> seedlist = new ArrayList<Integer>(); if (currentobject.get(index).length >= length) { seedlist.add(currentobject.get(index).seedID); if (frameseed.get(currentobject.get(index).Framenumber) != null && frameseed.get(currentobject.get(index).Framenumber) != Double.NaN) { int currentcount = frameseed.get(currentobject.get(index).Framenumber); frameseed.put(currentobject.get(index).Framenumber, seedlist.size() + currentcount); } else if (currentobject.get(index) != null) frameseed.put(currentobject.get(index).Framenumber, seedlist.size()); } } } } // Get maxima length, count int maxvalue = Integer.MIN_VALUE; for (int key : frameseed.keySet()) { int Count = frameseed.get(key); if (Count >= maxvalue) maxvalue = Count; } if (maxvalue != Integer.MIN_VALUE) { counterseries.add(length, maxvalue); if (maxvalue > 0) { Logcounterseries.add((length), Math.log(maxvalue)); points.add(new Point(new double[] { length, Math.log(maxvalue) })); } } } final XYSeriesCollection dataset = new XYSeriesCollection(); final XYSeriesCollection nofitdataset = new XYSeriesCollection(); dataset.addSeries(counterseries); nofitdataset.addSeries(counterseries); final XYSeriesCollection Logdataset = new XYSeriesCollection(); Logdataset.addSeries(Logcounterseries); final JFreeChart chart = ChartFactory.createScatterPlot("MT length distribution", "Number of MT", "Length (micrometer)", dataset); final JFreeChart nofitchart = ChartFactory.createScatterPlot("MT length distribution", "Number of MT", "Length (micrometer)", nofitdataset); // Fitting line to log of the length distribution interpolation.Polynomial poly = new interpolation.Polynomial(1); try { poly.fitFunction(points); } catch (NotEnoughDataPointsException e) { // TODO Auto-generated catch block e.printStackTrace(); } DisplayPoints.display(nofitchart, new Dimension(800, 500)); dataset.addSeries(Tracking.drawexpFunction(poly, counterseries.getMinX(), counterseries.getMaxX(), 0.5, "Exponential fit")); NumberFormat nf = NumberFormat.getInstance(Locale.ENGLISH); nf.setMaximumFractionDigits(3); TextTitle legendText = new TextTitle("Mean Length" + " : " + nf.format(-1.0 / poly.getCoefficients(1)) + " " + "Standard Deviation" + " : " + nf.format(poly.SSE)); legendText.setPosition(RectangleEdge.RIGHT); DisplayPoints.display(chart, new Dimension(800, 500)); chart.addSubtitle(legendText); final JFreeChart logchart = ChartFactory.createScatterPlot("MT Log length distribution", "Number of MT", "Length (micrometer)", Logdataset); // DisplayPoints.display(logchart, new Dimension(800, 500)); for (int i = 1; i >= 0; --i) System.out.println(poly.getCoefficients(i) + " " + "x" + " X to the power of " + i); // Logdataset.addSeries(Tracking.drawFunction(poly, counterseries.getMinX(), counterseries.getMaxX(), 0.5, "Straight line fit")); WriteLengthdistroFile(AllMovies, counterseries, 0); }