Example usage for java.lang Double NaN

List of usage examples for java.lang Double NaN

Introduction

In this page you can find the example usage for java.lang Double NaN.

Prototype

double NaN

To view the source code for java.lang Double NaN.

Click Source Link

Document

A constant holding a Not-a-Number (NaN) value of type double .

Usage

From source file:net.malariagen.gatk.math.SaddlePointExpansion.java

/**
 * A part of the deviance portion of the saddle point approximation.
 * <p>//from w  w w. ja  v a 2s .co  m
 * References:
 * <ol>
 * <li>Catherine Loader (2000). "Fast and Accurate Computation of Binomial
 * Probabilities.". <a target="_blank"
 * href="http://www.herine.net/stat/papers/dbinom.pdf">
 * http://www.herine.net/stat/papers/dbinom.pdf</a></li>
 * </ol>
 * </p>
 *
 * @param x the x value.
 * @param mu the average.
 * @return a part of the deviance.
 */
static double getDeviancePart(double x, double mu) {
    double ret;
    if (FastMath.abs(x - mu) < 0.1 * (x + mu)) {
        double d = x - mu;
        double v = d / (x + mu);
        double s1 = v * d;
        double s = Double.NaN;
        double ej = 2.0 * x * v;
        v = v * v;
        int j = 1;
        while (s1 != s) {
            s = s1;
            ej *= v;
            s1 = s + ej / ((j * 2) + 1);
            ++j;
        }
        ret = s1;
    } else {
        ret = x * FastMath.log(x / mu) + mu - x;
    }
    return ret;
}

From source file:edu.dfci.cccb.mev.deseq.domain.simple.FileBackedDESeq.java

private Double number(int index, String[] split) {
    String value = string(index, split);
    if ("Inf".equals(value))
        return Double.POSITIVE_INFINITY;
    else if ("-Inf".equals(value))
        return Double.NEGATIVE_INFINITY;
    else if ("NA".equals(value))
        return Double.NaN;
    else/*  www  . ja v a  2s  .c o  m*/
        return parseDouble(value);
}

From source file:org.jfree.chart.demo.SampleXYSymbolicDataset.java

/**
 * Returns the x-value (as a double primitive) for an item within a series.
 * /*from   w  w  w . ja v a  2s  .  c  o m*/
 * @param series
 *           the series (zero-based index).
 * @param item
 *           the item (zero-based index).
 * @return The x-value.
 */
public double getX(int series, int item) {
    double result = Double.NaN;
    Number x = getXValue(series, item);
    if (x != null) {
        result = x.doubleValue();
    }
    return result;
}

From source file:com.bdaum.zoom.gps.internal.GpsUtilities.java

public static double fetchElevation(double lat, double lon) throws IOException, HttpException {
    IGeocodingService service = GpsActivator.getDefault().getNamingServiceById("GeoNames"); //$NON-NLS-1$
    return service == null ? Double.NaN : service.getElevation(lat, lon);
}

From source file:com.rapidminer.tools.expression.internal.function.AntlrParserTrigonometricTest.java

@Test
public void sinInf() {
    try {/* w ww. j av  a2 s .co m*/
        Expression expression = getExpressionWithFunctionContext("sin(INFINITY)");
        assertEquals(ExpressionType.DOUBLE, expression.getExpressionType());
        assertEquals(Double.NaN, expression.evaluateNumerical(), 1e-15);
    } catch (ExpressionException e) {
        assertNotNull(e.getMessage());
    }
}

From source file:com.itemanalysis.psychometrics.measurement.ClassicalItemStatistics.java

public double getDindexLower() {
    if (dIndex) {
        return lower.getResult();
    } else {/*  w  w w .  ja  v  a 2  s. c  om*/
        return Double.NaN;
    }
}

From source file:edu.cmu.tetrad.search.TimeSeriesUtils.java

public static DataSet ar2(DataSet timeSeries, int numLags) {
    List<Node> missingVariables = new ArrayList<>();

    for (Node node : timeSeries.getVariables()) {
        int index = timeSeries.getVariables().indexOf(node);
        boolean missing = true;

        for (int i = 0; i < timeSeries.getNumRows(); i++) {
            if (!Double.isNaN(timeSeries.getDouble(i, index))) {
                missing = false;//from   w  w  w . j a v a  2 s  .  co m
                break;
            }
        }

        if (missing) {
            missingVariables.add(node);
        }
    }

    DataSet timeLags = createLagData(timeSeries, numLags);

    Regression regression = new RegressionDataset(timeLags);

    TetradMatrix residuals = new TetradMatrix(timeLags.getNumRows(), timeSeries.getNumColumns());

    for (int i = 0; i < timeSeries.getNumColumns(); i++) {
        Node target = timeLags.getVariable(i);
        int index = timeSeries.getVariables().indexOf(target);

        if (missingVariables.contains(target)) {
            for (int i2 = 0; i2 < residuals.rows(); i2++) {
                residuals.set(i2, index, Double.NaN);
            }

            continue;
        }

        List<Node> regressors = new ArrayList<>();

        for (int i2 = timeSeries.getNumColumns(); i2 < timeLags.getNumColumns(); i2++) {
            int varIndex = i2 % timeSeries.getNumColumns();
            Node var = timeSeries.getVariable(varIndex);

            if (missingVariables.contains(var)) {
                continue;
            }

            regressors.add(timeLags.getVariable(i2));
        }

        RegressionResult result = regression.regress(target, regressors);
        TetradVector residualsColumn = result.getResiduals();
        residuals.assignColumn(i, residualsColumn);
    }

    return ColtDataSet.makeContinuousData(timeSeries.getVariables(), residuals);
}

From source file:Float11.java

static public double log(double x) {
    if (!(x > 0.))
        return Double.NaN;
    ///*from ww w  .  j  a va 2 s  . c om*/
    if (x == 1.0)
        return 0.0;
    // Argument of _log must be (0; 1]
    if (x > 1.) {
        x = 1 / x;
        return -_log(x);
    }
    //
    return _log(x);
}

From source file:it.unibo.alchemist.model.SAPEREIncarnation.java

@SuppressFBWarnings(value = "ES_COMPARING_PARAMETER_STRING_WITH_EQ", justification = "Pointer comparison is intentional")
@Override/*from   w  ww .  ja  v a 2 s  .  com*/
public double getProperty(final Node<List<ILsaMolecule>> node, final Molecule mol, final String prop) {
    if (mol instanceof ILsaMolecule && node instanceof ILsaNode && node.contains(mol)) {
        boolean cacheUpdated = false;
        if (!mol.equals(molCache) || prop != propCache) { // NOPMD: reference comparison is intentional
            molCache = mol;
            propCache = prop;
            cacheUpdated = true;
        }
        return sapereProperty((ILsaNode) node, (ILsaMolecule) mol, prop, cacheUpdated);
    }
    return Double.NaN;
}

From source file:info.fetter.rrdclient.FetchCommand.java

private void parseDataLine(String line) {
    String[] explodedLine = line.split(":");
    String dateString, dataString;
    try {/*w  w  w  .  j av  a  2  s .  c  o m*/
        dateString = explodedLine[0];
        dataString = explodedLine[1].trim();

        Date date = new Date(Long.parseLong(dateString) * 1000);
        String[] dataArray = dataString.split(" ");
        ArrayList<Double> data = new ArrayList<Double>(dataArray.length);
        for (String value : dataArray) {
            try {
                data.add(Double.parseDouble(value));
            } catch (NumberFormatException e) {
                data.add(Double.NaN);
            }
        }
        table.addRow(date, data);
    } catch (Exception e) {
        //logger.debug("Error parsing line : " + line);
        throw new RuntimeException("Error parsing line : " + line, e);
    }
}