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:com.itemanalysis.psychometrics.histogram.Bin.java
/** * Gets the mean of the bin.// w ww . j av a 2 s.co m * * @return bin mean. */ public double getBinMean() { if (count == 0.0) return Double.NaN; return sum / count; }
From source file:lirmm.inria.fr.math.BigSparseRealMatrixTest.java
@Test public void testMath870() { // Caveat: This implementation assumes that, for any {@code x}, // the equality {@code x * 0d == 0d} holds. But it is is not true for // {@code NaN}. Moreover, zero entries will lose their sign. // Some operations (that involve {@code NaN} and/or infinities) may // thus give incorrect results. BigSparseRealMatrix a = new BigSparseRealMatrix(3, 3); BigSparseRealMatrix x = new BigSparseRealMatrix(3, 1); x.setEntry(0, 0, Double.NaN); x.setEntry(2, 0, Double.NEGATIVE_INFINITY); BigSparseRealMatrix b = a.multiply(x); for (int i = 0; i < b.getRowDimension(); ++i) { for (int j = 0; j < b.getColumnDimension(); ++j) { // NaNs and infinities have disappeared, this is a limitation of our implementation Assert.assertEquals(0.0, b.getEntry(i, j), 1.0e-20); }/*from ww w . j a va 2 s. c o m*/ } }
From source file:jasima.core.statistics.SummaryStat.java
/** * Returns the sample variance of the values. * //from w w w . j a v a 2 s . c o m * @return The (sample) variance of all values given to * {@link #value(double)}. Returns NaN, if no values were added yet. */ public double variance() { if (numObs < 1) return Double.NaN; if (numObs == 1) return 0.0; if (weightSum <= 1.0) throw new IllegalStateException("weight sum is <=1.0: " + weightSum); return varEst / (weightSum - 1.0); }
From source file:org.opennms.ng.dao.support.DefaultRrdDao.java
/** * <p>getPrintValues</p>/*ww w . j a v a2 s.co m*/ * * @param attribute a {@link org.opennms.netmgt.model.OnmsAttribute} object. * @param rraConsolidationFunction a {@link String} object. * @param startTimeInMillis a long. * @param endTimeInMillis a long. * @param printFunctions a {@link String} object. * @return an array of double. */ @Override public double[] getPrintValues(OnmsAttribute attribute, String rraConsolidationFunction, long startTimeInMillis, long endTimeInMillis, String... printFunctions) { Assert.notNull(attribute, "attribute argument must not be null"); Assert.notNull(rraConsolidationFunction, "rraConsolicationFunction argument must not be null"); Assert.isTrue(endTimeInMillis > startTimeInMillis, "end argument must be after start argument"); Assert.isAssignable(attribute.getClass(), RrdGraphAttribute.class, "attribute argument must be assignable to RrdGraphAttribute"); // if no printFunctions are given just use the rraConsolidationFunction if (printFunctions.length < 1) { printFunctions = new String[] { rraConsolidationFunction }; } RrdGraphAttribute rrdAttribute = (RrdGraphAttribute) attribute; String[] command = new String[] { m_rrdBinaryPath, "graph", "-", "--start=" + (startTimeInMillis / 1000), "--end=" + (endTimeInMillis / 1000), "DEF:ds=" + RrdFileConstants.escapeForGraphing(rrdAttribute.getRrdRelativePath()) + ":" + attribute.getName() + ":" + rraConsolidationFunction, }; String[] printDefs = new String[printFunctions.length]; for (int i = 0; i < printFunctions.length; i++) { printDefs[i] = "PRINT:ds:" + printFunctions[i] + ":\"%le\""; } String commandString = StringUtils.arrayToDelimitedString(command, " ") + ' ' + StringUtils.arrayToDelimitedString(printDefs, " "); LOG.debug("commandString: {}", commandString); RrdGraphDetails graphDetails; try { graphDetails = m_rrdStrategy.createGraphReturnDetails(commandString, m_rrdBaseDirectory); } catch (Throwable e) { throw new DataAccessResourceFailureException( "Failure when generating graph to get data with command '" + commandString + "'", e); } String[] printLines; try { printLines = graphDetails.getPrintLines(); } catch (Throwable e) { throw new DataAccessResourceFailureException( "Failure to get print lines from graph after graphing with command '" + commandString + "'", e); } if (printLines.length != printFunctions.length) { throw new DataAccessResourceFailureException("Returned number of print lines should be " + printFunctions.length + ", but was " + printLines.length + " from command: " + commandString); } double[] values = new double[printLines.length]; for (int i = 0; i < printLines.length; i++) { if (printLines[i].endsWith("nan")) { values[i] = Double.NaN; } else { try { values[i] = Double.parseDouble(printLines[i]); } catch (NumberFormatException e) { throw new DataAccessResourceFailureException("Value of line " + (i + 1) + " of output from RRD is not a valid floating point number: '" + printLines[i] + "'"); } } } return values; }
From source file:net.femtoparsec.jnlmin.AbstractTokenTask.java
private void dispatchRunning() { if (this.listeners.isEmpty()) { return;/* ww w.jav a2 s .c om*/ } MinimizerEventImpl event = new MinimizerEventImpl(); event.setMinimizerStatus(MinimizerStatus.RUNNING); event.setNbEvaluations(0); event.setNbIterations(0); event.setParameters(this.getFirstGuess()); event.setPenalty(Double.NaN); this.dispatchEvent(event); }
From source file:de.bund.bfr.math.Evaluator.java
public static double[] getDiffPoints(Map<String, Double> parserConstants, Map<String, String> functions, Map<String, Double> initValues, Map<String, String> initParameters, Map<String, List<Double>> conditionLists, String dependentVariable, Map<String, Double> independentVariables, String varX, double[] valuesX, IntegratorFactory integrator, InterpolationFactory interpolator) throws ParseException { DiffFunctionConf function = new DiffFunctionConf(parserConstants, functions, initValues, initParameters, conditionLists, dependentVariable, independentVariables, varX, valuesX, integrator, interpolator); double[] result = diffResults.getIfPresent(function); if (result != null) { return result; }/* w w w. j av a 2s .c o m*/ List<ASTNode> fs = new ArrayList<>(); List<String> valueVariables = new ArrayList<>(); double[] values = new double[functions.size()]; Parser parser = new Parser(); parserConstants.forEach((constant, value) -> parser.setVarValue(constant, value)); int index = 0; for (Map.Entry<String, String> entry : functions.entrySet()) { String var = entry.getKey(); fs.add(parser.parse(entry.getValue())); valueVariables.add(var); values[index++] = initValues.containsKey(var) ? initValues.get(var) : parserConstants.get(initParameters.get(var)); } Map<String, UnivariateFunction> variableFunctions = MathUtils.createInterpolationFunctions(conditionLists, varX, interpolator); FirstOrderDifferentialEquations f = MathUtils.createDiffEquations(parser, fs, valueVariables, varX, variableFunctions); FirstOrderIntegrator instance = integrator.createIntegrator(); double diffValue = conditionLists.get(varX).get(0); int depIndex = valueVariables.indexOf(dependentVariable); double[] valuesY = new double[valuesX.length]; for (int i = 0; i < valuesX.length; i++) { if (valuesX[i] == diffValue) { valuesY[i] = values[depIndex]; } else if (valuesX[i] > diffValue) { instance.integrate(f, diffValue, values, valuesX[i], values); diffValue = valuesX[i]; valuesY[i] = values[depIndex]; } else { valuesY[i] = Double.NaN; } } diffResults.put(function, valuesY); return valuesY; }
From source file:org.jfree.data.general.DefaultHeatMapDatasetTest.java
/** * Confirm that cloning works./*from ww w . ja va2 s.c o m*/ */ @Test public void testCloning() throws CloneNotSupportedException { DefaultHeatMapDataset d1 = new DefaultHeatMapDataset(2, 3, -1.0, 4.0, -2.0, 5.0); d1.setZValue(0, 0, 10.0); d1.setZValue(0, 1, Double.NEGATIVE_INFINITY); d1.setZValue(0, 2, Double.POSITIVE_INFINITY); d1.setZValue(1, 0, Double.NaN); DefaultHeatMapDataset d2 = (DefaultHeatMapDataset) d1.clone(); assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); // simple check for independence d1.setZValue(0, 0, 11.0); assertFalse(d1.equals(d2)); d2.setZValue(0, 0, 11.0); assertTrue(d1.equals(d2)); }
From source file:edu.purdue.cc.bionet.ui.HeatMap.java
/** * Returns a new DefaultHeatMapDataset for use in drawing the HeatMap. * //from w w w .j a va2 s . com * @return The DefaultHeatMapDataset. */ private DefaultHeatMapDataset getDataset() { int size = moleculeList.size(); DefaultHeatMapDataset returnValue = new DefaultHeatMapDataset(size, size, 0.0, (double) size, 0.0, (double) size); for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { returnValue.setZValue(i, j, (i == j) ? Double.NaN : this.correlations.getCorrelation(moleculeList.get(i), moleculeList.get(j)) .getValue(correlationMethod)); } } return returnValue; }
From source file:com.itemanalysis.psychometrics.statistics.TwoWayTable.java
public double getRowPct(Comparable<?> rowValue) { long rowTotal = rowMargin.getSumFreq(); if (rowTotal == 0) { return Double.NaN; }// ww w. j a v a 2s .c om return (double) getRowCount(rowValue) / (double) rowTotal; }
From source file:net.cit.tetrad.data.convert.DataConvertThread.java
private void createTetradRrdDb(Device device, String dbname, List<StatusDatasourceName> dsNameList) throws Exception { String rrdPath = null;//w w w . jav a 2 s . c om try { String dsName; for (StatusDatasourceName dbstatusInfo : dsNameList) { dsName = dbstatusInfo.getDsName(); rrdPath = CommonUtils.makeRrdDbPath(device, dbname, dsName); // ? row ? int intervalTime = RrdUtil.readLogGenerationInterval(); RrdDef rrdDef = new RrdDef(rrdPath, Util.getTimestamp(START_DATE), intervalTime); DsType dsType = DsType.valueOf(dbstatusInfo.getDsType()); rrdDef.addDatasource(StringUtil.rightSubstring(dsName, 20), dsType, intervalTime * 2, 0, Double.NaN); rrdDef.addArchive(ConsolFun.LAST, 0.5, RRD_STEP_SECOND, RrdUtil.calculateCreateRowCnt(360)); rrdDef.addArchive(ConsolFun.LAST, 0.5, RRD_STEP_MINUTE, RrdUtil.calculateCreateRowCnt(60)); rrdDef.addArchive(ConsolFun.LAST, 0.5, RRD_STEP_5MINUTE, RrdUtil.calculateCreateRowCnt(12)); rrdDef.addArchive(ConsolFun.LAST, 0.5, RRD_STEP_30MINUTE, RrdUtil.calculateCreateRowCnt(2)); rrdDef.addArchive(ConsolFun.LAST, 0.5, RRD_STEP_HOUR, RrdUtil.calculateCreateRowCnt(1)); rrdDef.addArchive(ConsolFun.AVERAGE, 0.5, RRD_STEP_SECOND, RrdUtil.calculateCreateRowCnt(360)); rrdDef.addArchive(ConsolFun.AVERAGE, 0.5, RRD_STEP_MINUTE, RrdUtil.calculateCreateRowCnt(60)); rrdDef.addArchive(ConsolFun.AVERAGE, 0.5, RRD_STEP_5MINUTE, RrdUtil.calculateCreateRowCnt(12)); rrdDef.addArchive(ConsolFun.AVERAGE, 0.5, RRD_STEP_30MINUTE, RrdUtil.calculateCreateRowCnt(2)); rrdDef.addArchive(ConsolFun.AVERAGE, 0.5, RRD_STEP_HOUR, RrdUtil.calculateCreateRowCnt(1)); rrdDef.addArchive(ConsolFun.TOTAL, 0.5, RRD_STEP_SECOND, RrdUtil.calculateCreateRowCnt(360)); rrdDef.addArchive(ConsolFun.TOTAL, 0.5, RRD_STEP_MINUTE, RrdUtil.calculateCreateRowCnt(60)); rrdDef.addArchive(ConsolFun.TOTAL, 0.5, RRD_STEP_5MINUTE, RrdUtil.calculateCreateRowCnt(12)); rrdDef.addArchive(ConsolFun.TOTAL, 0.5, RRD_STEP_30MINUTE, RrdUtil.calculateCreateRowCnt(2)); rrdDef.addArchive(ConsolFun.TOTAL, 0.5, RRD_STEP_HOUR, RrdUtil.calculateCreateRowCnt(1)); // RrdDb ?. RrdDb rrdDb = new RrdDb(rrdDef); rrdDb.close(); } } catch (Exception e) { throw e; } }