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:edu.cornell.med.icb.goby.stats.TTestCalculator.java

@Override
public DifferentialExpressionInfo evaluate(
        final DifferentialExpressionCalculator differentialExpressionCalculator,
        final NormalizationMethod method, final DifferentialExpressionResults results,
        final DifferentialExpressionInfo info, final String... group) {
    final String groupA = group[0];
    final String groupB = group[1];
    final ObjectArraySet<String> samplesA = differentialExpressionCalculator.getSamples(groupA);
    final ObjectArraySet<String> samplesB = differentialExpressionCalculator.getSamples(groupB);
    if (samplesA.size() < 2 || samplesB.size() < 2) {
        return info;
    }/*from   w  w w. j a  v  a2s  .c  o m*/

    final int tTestStatIndex = defineStatisticId(results, "t-test", method, group);
    final int tStatisticStatIndex = defineStatisticId(results, "t-statistic", method, group);

    final double[] valuesA = new double[samplesA.size()];
    final double[] valuesB = new double[samplesB.size()];

    int i = 0;
    for (final String sample : samplesA) {
        valuesA[i++] = StrictMath.log1p(differentialExpressionCalculator.getNormalizedExpressionValue(sample,
                method, info.getElementId()));
    }

    i = 0;
    for (final String sample : samplesB) {
        valuesB[i++] = StrictMath.log1p(differentialExpressionCalculator.getNormalizedExpressionValue(sample,
                method, info.getElementId()));
    }

    double pValue = 0;
    double tStatistic = 0;

    try {
        pValue = mathCommonsTTest.homoscedasticTTest(valuesA, valuesB);
        tStatistic = mathCommonsTTest.t(valuesA, valuesB);
    } catch (MathException e) {
        pValue = Double.NaN;
    }

    info.statistics.size(results.getNumberOfStatistics());
    info.statistics.set(tTestStatIndex, pValue);
    info.statistics.set(tStatisticStatIndex, tStatistic);

    return info;
}

From source file:com.bmwcarit.barefoot.matcher.MatcherSample.java

/**
 * Creates a {@link MatcherSample} object from its JSON representation.
 *
 * @param json JSON representation of {@link MatcherSample} object. JSONException thrown on JSON
 *        extraction or parsing error.//from ww  w.  j a va2s.  com
 * @throws JSONException thrown on JSON parse error.
 */
public MatcherSample(JSONObject json) throws JSONException {
    super(json);
    id = json.getString("id");
    String wkt = json.getString("point");
    point = (Point) GeometryEngine.geometryFromWkt(wkt, WktImportFlags.wktImportDefaults, Type.Point);
    if (json.has("azimuth")) {
        azimuth = norm(json.getDouble("azimuth"));
    } else {
        azimuth = Double.NaN;
    }
}

From source file:com.bazaarvoice.jolt.SortrTest.java

@Test
public void testDoesNotBlowUpOnUnmodifiableArray() {
    List<Object> hasNan = new ArrayList<>();
    hasNan.add(1);/*w  w w . j a  v  a 2 s .  c  o  m*/
    hasNan.add(Double.NaN);
    hasNan.add(2);

    Map<String, Object> map = new HashMap<>();
    map.put("a", "shouldBeFirst");
    map.put("hasNan", Collections.unmodifiableList(hasNan));

    try {
        Sortr.sortJson(map);
    } catch (UnsupportedOperationException uoe) {
        Assert.fail("Sort threw a UnsupportedOperationException");
    }
}

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

public Double varY(boolean unbiased) {
    if (N < 1)
        return Double.NaN;
    if (unbiased) {
        return varNumeratorY / (N - 1.0);
    } else {/* w w  w.java  2 s .  c o  m*/
        return varNumeratorY / N;
    }
}

From source file:edu.ucdenver.bios.statisticaltest.HotellingLawleyTraceTest.java

/**
 * Calculate the denominator degrees of freedom for the HLT, based on
 * whether the null or alternative hypothesis is assumed true.  
 * // w w w  .  j a  va  2s  .  co  m
 * @param type distribution type
 * @return denominator degrees of freedom
 * @throws IllegalArgumentException
 */
private double getDenominatorDF() {
    // minimum of a and b dimensions
    double s = (a < b) ? a : b;

    double df = Double.NaN;
    if (fMethod == FApproximation.PILLAI_ONE_MOMENT || fMethod == FApproximation.PILLAI_ONE_MOMENT_OMEGA_MULT) {
        df = s * (nuE - b - 1) + 2;
    } else {
        double t1 = nuE * nuE - nuE * (2 * b + 3) + b * (b + 3);
        double t2 = (nuE * (a + b + 1) - (a + 2 * b + b * b - 1));
        df = 4 + (a * b + 2) * (t1 / t2);
    }
    // TODO Auto-generated method stub
    return df;
}

From source file:edu.cuny.qc.speech.AuToBI.core.Aggregation.java

/**
 * Removes a value from the Aggregation.
 * <p/>//  ww w . j  a  va 2  s. c  o  m
 * Removing a value from an Aggregation can invalidate its minimum and maximum calculation if the value was equal to
 * the current minmum or maximum.
 * <p/>
 * Note: no check is made that the value was ever initially added to the Aggregation.
 *
 * @param v the value
 */
public void remove(Double v) {
    sum -= v;
    ssq -= (v * v);
    if (v.equals(max)) {
        max = Double.NaN; // no running max and min
    }
    if (v.equals(min)) {
        min = Double.NaN;
    }
    n--;
}

From source file:com.fay.statics.SummaryStat.java

public double sum() {
    if (numObs < 1)
        return Double.NaN;
    return valSum;
}

From source file:org.jfree.data.time.ohlc.OHLCItem.java

/**
 * Returns the close value./*  w w w.  j ava 2 s.  co m*/
 *
 * @return The close value.
 */
public double getCloseValue() {
    OHLC ohlc = (OHLC) getObject();
    if (ohlc != null) {
        return ohlc.getClose();
    } else {
        return Double.NaN;
    }
}

From source file:at.uni_salzburg.cs.ckgroup.cscpp.mapper.algorithm.VehicleStatusTestCase.java

@Test
public void testCase02() throws ParseException {
    String status = "{\"vehicle.id\":\"732d463b-6836-487c-989d-47c59285c17d\",\"state\":\"corrupt\",\"latitude\":47.8226984,\"longitude\":13.04211393,\"altitude\":25.0,"
            + "\"tolerance\":12.0,\"actions\":\"photo,temperature\"}";
    JSONParser parser = new JSONParser();
    VehicleStatus s = new VehicleStatus((JSONObject) parser.parse(status));
    Assert.assertEquals("732d463b-6836-487c-989d-47c59285c17d", s.getId());
    Assert.assertEquals("corrupt", s.getState().toString().toLowerCase());
    Assert.assertNull(s.getPosition());//from w  ww  .  jav  a  2 s  .  co  m
    Assert.assertEquals(Double.NaN, s.getTolerance(), 1E-9);
    Assert.assertNull(s.getActions());

    s = new VehicleStatus((JSONObject) parser.parse(s.toJSONString()));
    Assert.assertEquals("732d463b-6836-487c-989d-47c59285c17d", s.getId());
    Assert.assertEquals("corrupt", s.getState().toString().toLowerCase());
    Assert.assertNull(s.getPosition());
    Assert.assertEquals(Double.NaN, s.getTolerance(), 1E-9);
    Assert.assertNull(s.getActions());
}

From source file:de.taimos.gpsd4java.backend.AbstractResultParser.java

protected double parseTimestamp(final JSONObject json, final String fieldName) {
    try {/* w ww. j  a  v a2 s.c o  m*/
        final String text = json.optString(fieldName, null);
        AbstractResultParser.LOG.debug(fieldName + ": {}", text);

        if (text != null) {
            final Date date = this.dateFormat.parse(text);
            if (AbstractResultParser.LOG.isDebugEnabled()) {
                final String ds = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(date);
                AbstractResultParser.LOG.debug("Date: {}", ds);
            }
            return date.getTime() / 1000.0;
        }
    } catch (final Exception ex) {
        AbstractResultParser.LOG.info("Failed to parse time", ex);
    }
    return Double.NaN;
}