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:edu.toronto.cs.phenotips.measurements.internal.AbstractMeasurementHandler.java
@Override public double standardDeviationToValue(boolean male, int ageInMonths, double targetDeviation) { LMS lms = getLMSForAge(getLMSList(male), ageInMonths); if (lms == null) { return Double.NaN; }/* w w w.j a v a 2s .c o m*/ return standardDeviationToValue(targetDeviation, lms.m, lms.l, lms.s); }
From source file:game.plugins.algorithms.RealFeaturesTree.java
protected CriterionWithGain bestCriterionFor(int featureIndex, Dataset dataset) { CriterionWithGain ret = new CriterionWithGain(null, 0); List<FeatureValue> values = new ArrayList<>(dataset.size()); SampleIterator it = dataset.sampleIterator(); while (it.hasNext()) { Sample sample = it.next();// w ww . ja va 2s . c o m values.add(new FeatureValue(sample.getSource().get(featureIndex, RealVector.class).getEntry(0), sample.getTarget().get(String.class))); } Collections.sort(values); Map<String, Double> lesserCount = new HashMap<>(); Map<String, Double> greaterCount = countPerLabel(values); double information = information(greaterCount); double threshold = Double.NaN; FeatureValue prev = values.get(0); int count = 1; for (int i = 1; i < values.size(); i++) { FeatureValue curr = values.get(i); if (!lesserCount.containsKey(prev.label)) lesserCount.put(prev.label, 0.0); if (!prev.label.equals(curr.label)) { lesserCount.put(prev.label, lesserCount.get(prev.label) + count); greaterCount.put(prev.label, greaterCount.get(prev.label) - count); count = 1; if (prev.value < curr.value) { double gain = information + gain(lesserCount, greaterCount); if (gain > ret.gain) { threshold = (prev.value + curr.value) / 2; ret.gain = gain; } } } else { count++; } prev = curr; } if (!Double.isNaN(threshold)) { SingleThreshold c = new SingleThreshold(featureIndex, threshold); ret.criterion = c; } return ret; }
From source file:com.fay.statics.SummaryStat.java
public double confIntRangeSingle(double errorProb) { if (numObs <= 2) return Double.NaN; double deg = weightSum() - 1.0d; TDistribution dist = new TDistribution(deg); return Math.abs(dist.inverseCumulativeProbability(errorProb * 0.5d)) * Math.sqrt(variance() / weightSum()); }
From source file:com.itemanalysis.jmetrik.stats.ranking.RankingAnalysis.java
private ResizableDoubleArray getData() throws SQLException { Statement stmt = null;//from w w w . j av a2 s . c om ResultSet rs = null; ResizableDoubleArray data = new ResizableDoubleArray((int) (maxProgress / 2.0)); try { //connect to table to create data set to be ranked Table sqlTable = new Table(tableName.getNameForDatabase()); SelectQuery select = new SelectQuery(); select.addColumn(sqlTable, variable.getName().nameForDatabase()); stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); rs = stmt.executeQuery(select.toString()); String vNameDb = variable.getName().nameForDatabase(); double x = Double.NaN; int dbIndex = 0;//row position index for all records in db while (rs.next()) { x = rs.getDouble(vNameDb); if (!rs.wasNull()) { if (ascending) { data.addElement(x);//ascending order } else { data.addElement(-x);//descending order } } else { missingIndex.add(dbIndex); } dbIndex++; updateProgress(); } return data; } catch (SQLException ex) { throw ex; } finally { if (rs != null) rs.close(); if (stmt != null) stmt.close(); } }
From source file:eu.crisis_economics.utilities.EmpiricalDistribution.java
/** Get the last recorded value */ public double getLastAdded() { if (lastValueInserted == Double.NaN) throw new IllegalStateException("EmpiricalDistribution.getLastAdded: no records."); return lastValueInserted; }
From source file:jasima.core.statistics.SummaryStat.java
/** * Returns the mean of all values given to {@link #value(double)}. * // w w w. j av a 2 s . com * @return The arithmetic mean of all values seen so far. */ public double mean() { if (numObs < 1) return Double.NaN; return meanEst; }
From source file:es.ucm.fdi.ac.outlier.Hampel.java
/** * Ugly lookup of 'k' given alpha. Alpha must be either 0.01 or 0.05 * for this to work as expected./*from w w w.j a v a 2s. co m*/ */ private static double analyticK(int n, double alpha) { double k; double logN = Math.log(n); double sqrtTwoLogN = Math.sqrt(2 * logN); double z_n_alpha = sqrtTwoLogN - Math.log(alpha / 2) / sqrtTwoLogN - (Math.log(logN) + Math.log(4 * Math.PI)) / (2 * sqrtTwoLogN); if (alpha == 0.05) { if ((n % 2) == 0) {//N even k = 1.483 * z_n_alpha + 21.61 * Math.pow(n + 1, -0.8655); } else { k = 1.483 * z_n_alpha + 14.43 * Math.pow(n - 3, -0.7939); } return k; } else if (alpha == 0.01) { if ((n % 2) == 0) {//N even k = 1.483 * z_n_alpha + 41.39 * Math.pow(n, -0.9143); } else { k = 1.483 * z_n_alpha + 24.48 * Math.pow(n - 5, -0.8236); } return k; } else { return Double.NaN; // throw new IllegalArgumentException( // "Alpha IS RESTRICTED to be 0.01 or 0.05 "); } }
From source file:gda.plots.TurboXYItemRenderer.java
/** * Draws the visual representation of a single data item. This mostly reproduces the code of StandardXYItemRenderer * but using the line by line information stored in the SimpleXYSeries instead of the series indexed information * stored in the Renderer itself.//from w w w. j a va 2 s . c om * * @param g2 * the graphics device. * @param state * the renderer state. * @param dataArea * the area within which the data is being drawn. * @param info * collects information about the drawing. * @param plot * the plot (can be used to obtain standard color information etc). * @param domainAxis * the domain axis. * @param rangeAxis * the range axis. * @param dataset * the dataset. * @param series * the series index (zero-based). * @param crosshairState * crosshair information for the plot ( <code>null</code> permitted). * @param pass * the pass index. */ @Override public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int _item, CrosshairState crosshairState, int pass) { if (_item > 0) return; SimpleXYSeries sxys = (SimpleXYSeries) ((SimpleXYSeriesCollection) dataset).getSeries(series); if (!sxys.isVisible()) { return; } PlotOrientation orientation = plot.getOrientation(); g2.setPaint(sxys.getPaint()); g2.setStroke(sxys.getStroke()); RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); try { int x0 = -1; // the x position in pixels of the previous point int y0 = -1; // the y position in pixels of the previous point int x1 = -1; // the x position in pixels of the current point int y1 = -1; // the y position in pixels of the current point int xmin = (int) dataArea.getMinX(); int xmax = (int) dataArea.getMaxX(); int ymin = (int) dataArea.getMinY(); int ymax = (int) dataArea.getMaxY(); GeneralPath path = null; /* * To remove the time spent repeatedly calling domainAxis.valueToJava2D for linear axes use simple linear * maths */ double xl = 0., mx = Double.NaN, cx = 0.; if (domainAxis instanceof SimpleNumberAxis) { xl = domainAxis.getRange().getLowerBound(); mx = dataArea.getWidth() / (domainAxis.getRange().getUpperBound() - xl); cx = xmin; } double yl = 0., my = Double.NaN, cy = 0.; if (rangeAxis instanceof SimpleNumberAxis) { yl = rangeAxis.getRange().getLowerBound(); my = -dataArea.getHeight() / (rangeAxis.getRange().getUpperBound() - yl); cy = ymax; } List<XYDataItem> list = sxys.getData(); boolean MX_MY_NaN = Double.isNaN(mx) || Double.isNaN(my); Paint paint = sxys.getPaint(); Stroke stroke = sxys.getStroke(); Paint paint_symbol = sxys.getSymbolPaint(); Stroke stroke_symbol = new BasicStroke(); drawLines = sxys.isDrawLines(); boolean filled = sxys.getFilled(); Shape shape = sxys.getSymbol(); boolean drawMarkers = sxys.isDrawMarkers() & shape != null; int tooltipThresholdCounts = -1; /* number of points to be shown below which markers are also to be drawn */ if (drawLines && drawMarkers && shape != null && tooltipThreshold != 0) { Rectangle shapeBoundingBox = shape.getBounds(); tooltipThresholdCounts = (int) dataArea.getWidth() / (Math.max(1, shapeBoundingBox.width) * tooltipThreshold); } java.util.Vector<ddouble> markerPositions = null; Shape entityArea = null; EntityCollection entities = null; if (info != null) { entities = info.getOwner().getEntityCollection(); } boolean prevLineAdded = false; // In case the iterator does not work then use the TODO comment iterator use and why not always // comment variables synchronized (list) { Iterator<XYDataItem> iter = list.iterator(); /* * loop over all points calculating X1 and Y1. Store previous points positions into X0 and Y0 The * variable addThis determines if the current point is to be added to the path If previous line was * added that the current must be even if off the screen - but in this case the flag prevLineAdded is * set false so that the next does not have to be added. */ for (int item = 0; iter.hasNext(); item++, x0 = x1, y0 = y1, x1 = -1, y1 = -1) { XYDataItem dataitem = iter.next(); double x = dataitem.getX().doubleValue(); double y = dataitem.getY().doubleValue(); x = xValueTransformer.transformValue(x); x1 = MX_MY_NaN ? (int) domainAxis.valueToJava2D(x, dataArea, xAxisLocation) : (int) ((x - xl) * mx + cx); y1 = MX_MY_NaN ? (int) rangeAxis.valueToJava2D(y, dataArea, yAxisLocation) : (int) ((y - yl) * my + cy); boolean addThis = true; if (item == 0) { x0 = x1; y0 = y1; if ((x1 < xmin) || (x1 > xmax) || (y1 < ymin) || (y1 > ymax)) { addThis = false; } } else { if (x1 == x0 && y1 == y0) { addThis = false; } if ((x1 < xmin && x0 < xmin) || (x1 > xmax && x0 > xmax) || (y1 < ymin && y0 < ymin) || (y1 > ymax && y0 > ymax)) { if (prevLineAdded) { path = addPointToLine(path, orientation, x1, y1); } addThis = false; } } if (addThis) { /* * If the current point is to be added then ensure previous one is as well to prevent lines * not crossing the edge of the screen */ if (!prevLineAdded) { path = addPointToLine(path, orientation, x0, y0); } path = addPointToLine(path, orientation, x1, y1); prevLineAdded = true; } prevLineAdded = addThis; if (addThis && drawMarkers) { if (markerPositions == null) { markerPositions = new java.util.Vector<ddouble>(); } markerPositions.add(new ddouble(item, x1, y1)); if (tooltipThresholdCounts != -1 && markerPositions.size() > tooltipThresholdCounts) { drawMarkers = false; markerPositions = null; } } } if (path != null) { g2.setStroke(stroke); g2.setPaint(paint); g2.draw(path); } if (markerPositions != null) { if (drawMarkers) { g2.setPaint(paint_symbol); g2.setStroke(stroke_symbol); for (ddouble dd : markerPositions) { Shape shape_item = ShapeUtilities.createTranslatedShape(shape, dd.x, dd.y); if (filled) { g2.fill(shape_item); } else { g2.draw(shape_item); } entityArea = shape_item; // add an entity for the item... if (entities != null) { addEntity(entities, entityArea, dataset, series, dd.item, dd.x, dd.y); } } g2.setPaint(paint); g2.setStroke(stroke); } } } } catch (Exception e) { e.printStackTrace(); } }
From source file:edu.cmu.tetrad.search.IndTestConditionalGaussianLRT.java
/** * @return the probability associated with the most recently executed independence test, of Double.NaN if p value is * not meaningful for tis test./*from ww w.ja v a 2 s . c o m*/ */ public double getPValue() { return Double.NaN; }
From source file:com.clust4j.algo.preprocess.ImputationTests.java
@Test public void testKNNImputation() { final double[][] d = new double[][] { new double[] { 1, 1, 2 }, new double[] { 1, Double.NaN, 3 }, new double[] { 8.5, 7.9, 6 }, new double[] { 9, 8, Double.NaN } }; final NearestNeighborImputation nni = new NearestNeighborImputation( new NearestNeighborImputation.NNImputationPlanner().setK(1).setVerbose(true)); final double[][] imputed = nni.transform(d); final double[][] res = new double[][] { new double[] { 1, 1, 2 }, new double[] { 1, 1, 3 }, new double[] { 8.5, 7.9, 6 }, new double[] { 9, 8, 6 } }; assertTrue(MatUtils.equalsExactly(res, imputed)); System.out.println();/* www .j a v a 2 s.c o m*/ }