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:org.sloth.validation.CoordinateValidatorTest.java

@Test
public void testEmptyLongitude() {
    CoordinateValidator cv = new CoordinateValidator();
    Coordinate c = new Coordinate();
    c.setLongitude(Double.NaN);
    Errors errors = new BeanPropertyBindingResult(c, "coordinate");
    cv.validate(c, errors);/* w ww.  j  av  a 2s . co m*/
    assertTrue(errors.hasErrors());
    assertEquals(COORDINATE.EMPTY_LONGITUDE, errors.getFieldError("longitude").getCode());
}

From source file:com.clust4j.algo.preprocess.ImputationTests.java

@Test
public void testMeanImputation() {
    final double[][] d = new double[][] { new double[] { Double.NaN, 1, 2 }, new double[] { 1, Double.NaN, 3 },
            new double[] { 2, 2, 1 } };

    final MeanImputation mean = new MeanImputation(new MeanImputationPlanner().setVerbose(true));

    final double[][] imputed = mean.transform(d);
    final double[][] res = new double[][] { new double[] { 1.5, 1, 2 }, new double[] { 1, 1.5, 3 },
            new double[] { 2, 2, 1 } };

    assertTrue(MatUtils.equalsExactly(res, imputed));
    System.out.println();/*  www.  ja  va 2 s  .  com*/
}

From source file:de.hs.mannheim.modUro.diagram.JCellcycletimeDiagram.java

private XYDataset createDataset(List<String> cellTypes, List<CellCycletimeEntry> cycletimesList) {

    XYSeriesCollection dataset = new XYSeriesCollection();

    for (String cellType : cellTypes) {
        XYSeries xySerie = new XYSeries(cellType);
        for (CellCycletimeEntry e : cycletimesList) {
            double x = e.time;
            double y = 0;
            if (e.meanValues.containsKey(cellType)) {
                y = (double) e.meanValues.get(cellType);
            }/*w  ww  .j  ava2s.  c  o m*/
            if (y != Double.NaN) {
                xySerie.add(x, y);
            }
        }
        dataset.addSeries(xySerie);
    }
    return dataset;
}

From source file:com.itemanalysis.psychometrics.polycor.PearsonCorrelation.java

/**
 * Correct correlation for spuriousness. This method assumes that
 * the test item is Y and the test score is X. Used for the
  * point-biserial and biserial correlation in an item analysis.
 *
 * @return correlation corrected for spuriousness
 *//*w ww.  j a  v a 2  s  .com*/
public Double correctedValue() {
    double testSd = sdX.getResult();
    double itemSd = sdY.getResult();
    double rOld = this.value();
    double denom = Math.sqrt(itemSd * itemSd + testSd * testSd - 2 * rOld * itemSd * testSd);
    if (denom == 0.0)
        return Double.NaN;
    return (rOld * testSd - itemSd) / denom;
}

From source file:mase.spec.SilhouetteDistanceCalculator.java

@Override
public double[][] computeDistances(List<BehaviourResult>[] list, EvolutionState state) {
    List<BehaviourResult> all = new ArrayList<>();
    int[][] alloc = new int[list.length][];
    int index = 0;

    for (int i = 0; i < list.length; i++) {
        alloc[i] = new int[list[i].size()];
        all.addAll(list[i]);/*from   ww  w .ja v  a2  s  .c om*/
        for (int j = 0; j < list[i].size(); j++) {
            alloc[i][j] = index++;
        }
    }

    RealMatrix behavDist = null;
    if (!all.isEmpty()) {
        if (executor != null) {
            behavDist = computeDistanceMatrixParallel(all);
        } else {
            behavDist = computeDistanceMatrix(all);
        }
    }

    double[][] mpDist = new double[list.length][list.length];
    for (int i = 0; i < mpDist.length; i++) {
        for (int j = 0; j < mpDist.length; j++) {
            if (i == j) {
                mpDist[i][j] = Double.NaN;
            } else if (list[i].isEmpty() || list[j].isEmpty()) {
                mpDist[i][j] = Double.POSITIVE_INFINITY;
            } else if (i < j) {
                double wi = silhouetteWidth(alloc[i], alloc[j], behavDist, state);
                double wj = silhouetteWidth(alloc[j], alloc[i], behavDist, state);
                mpDist[i][j] = (wi + wj) / 2;
            } else {
                mpDist[i][j] = mpDist[j][i];
            }
        }
    }
    return mpDist;
}

From source file:net.aksingh.owmjapis.AbstractForecast.java

AbstractForecast() {
    super();

    this.message = Double.NaN;
    this.forecastCount = 0;
    this.city = null;
}

From source file:de.bund.bfr.math.LodFunction.java

@Override
public double value(double[] point) {
    double sd = Double.NaN;

    for (int ip = 0; ip < nParams; ip++) {
        if (parameters.get(ip).equals(sdParam)) {
            sd = Math.abs(point[ip]);
        } else {//  w w  w.j  a v a 2  s  . c o m
            parser.setVarValue(parameters.get(ip), point[ip]);
        }
    }

    if (sd == 0.0) {
        return Double.NaN;
    }

    double logLikelihood = 0.0;

    for (int iv = 0; iv < nValues; iv++) {
        for (Map.Entry<String, List<Double>> entry : variableValues.entrySet()) {
            parser.setVarValue(entry.getKey(), entry.getValue().get(iv));
        }

        try {
            double value = parser.evaluate(function);

            if (!Double.isFinite(value)) {
                return Double.NaN;
            }

            NormalDistribution normDist = new NormalDistribution(value, sd);

            logLikelihood += targetValues.get(iv) > levelOfDetection
                    ? Math.log(normDist.density(targetValues.get(iv)))
                    : Math.log(normDist.cumulativeProbability(levelOfDetection));
        } catch (ParseException e) {
            e.printStackTrace();
            return Double.NaN;
        }
    }

    return logLikelihood;
}

From source file:de.thkwalter.et.betriebspunkt.Betriebspunkt.java

/**
 * Dieser Konstruktor erzeugt einen Betriebspunkt und initialisiert alle reellwertigen Gren mit {@link Double#NaN}.
 */// ww  w.  j av  a2s .  c om
public Betriebspunkt() {
    // Alle reellwertigen Gren werden mit Double.NaN initialisiert.
    this.u_LL = Double.NaN;
    this.i_L = Double.NaN;
    this.cosPhi = Double.NaN;
    this.p_el = Double.NaN;
    this.p_s = Double.NaN;

    // Der komplexe Zeiger des Stnderstroms (in A) wird initialisiert.
    this.z_i_s = Complex.NaN;
}

From source file:at.alladin.rmbt.statisticServer.StatisticParameters.java

public StatisticParameters(String defaultLang, String params) {
    String _lang = defaultLang;/*  w w w.j  ava 2s. co  m*/
    float _quantile = 0.5f; // median is default quantile
    int _duration = 90;
    int _maxDevices = 100;
    String _type = "mobile";
    String _networkTypeGroup = null;
    double _accuracy = -1;
    String _country = null;

    if (params != null && !params.isEmpty())
        // try parse the string to a JSON object
        try {
            final JSONObject request = new JSONObject(params);
            _lang = request.optString("language", _lang);

            final double __quantile = request.optDouble("quantile", Double.NaN);
            if (__quantile >= 0 && __quantile <= 1)
                _quantile = (float) __quantile;

            final int __months = request.optInt("months", 0); // obsolete, old format (now in days)
            if (__months > 0)
                _duration = __months * 30;

            final int __duration = request.optInt("duration", 0);
            if (__duration > 0)
                _duration = __duration;

            final int __maxDevices = request.optInt("max_devices", 0);
            if (__maxDevices > 0)
                _maxDevices = __maxDevices;

            final String __type = request.optString("type", null);
            if (__type != null)
                _type = __type;

            final String __networkTypeGroup = request.optString("network_type_group", null);
            if (__networkTypeGroup != null && !__networkTypeGroup.equalsIgnoreCase("all"))
                _networkTypeGroup = __networkTypeGroup;

            final double __accuracy = request.optDouble("location_accuracy", -1);
            if (__accuracy != -1)
                _accuracy = __accuracy;

            final String __country = request.optString("country", null);
            if (__country != null && __country.length() == 2)
                _country = __country;
        } catch (final JSONException e) {
        }
    lang = _lang;
    quantile = _quantile;
    duration = _duration;
    maxDevices = _maxDevices;
    type = _type;
    networkTypeGroup = _networkTypeGroup;
    accuracy = _accuracy;
    country = _country;
}

From source file:com.mapr.synth.samplers.GammaSampler.java

@SuppressWarnings("UnusedDeclaration")
public void setRate(double rate) {
    this.beta = 1 / rate;

    dof = Double.NaN;
    scale = Double.NaN;//from w  w w .j  a v  a  2 s .co  m
    init();
}