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.aksingh.owmjapis.AbstractForecast.java

AbstractForecast(JSONObject jsonObj) {
    super(jsonObj);

    this.message = (jsonObj != null) ? jsonObj.optDouble(JSON_MESSAGE, Double.NaN) : Double.NaN;

    this.city = (jsonObj != null) ? new City(jsonObj.optJSONObject(JSON_CITY)) : null;

    this.forecastCount = (jsonObj != null) ? jsonObj.optInt(JSON_FORECAST_COUNT, 0) : 0;
}

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

@SuppressWarnings("UnusedDeclaration")
public void setBeta(double beta) {
    this.beta = beta;

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

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

public double get(int variable, int[] parents) {
    Set<Integer> _parents = new HashSet<Integer>(parents.length);

    for (int parent : parents) {
        _parents.add(parent);//from w w w .  ja v  a2 s  . c  om
    }

    Double _score = (Double) map.get(variable, _parents);
    return _score == null ? Double.NaN : (_score);
}

From source file:de.hs.mannheim.modUro.reader.JCellCountDiagram.java

private XYDataset createDataset(List<String> cellTypes, List<CellCountEntry> cellcountList) {

    XYSeriesCollection dataset = new XYSeriesCollection();

    XYSeries xySerieSum = new XYSeries("total");
    for (String cellType : cellTypes) {
        XYSeries xySerie = new XYSeries(cellType);
        for (CellCountEntry e : cellcountList) {
            double x = e.time;
            double y = 0;
            if (e.count.containsKey(cellType)) {
                y = (double) e.count.get(cellType);
            }/*from   w ww.  j  a  v a 2s .com*/
            xySerie.add(x, y);
        }
        dataset.addSeries(xySerie);
    }
    for (CellCountEntry e : cellcountList) {
        double x = e.time;
        double y = e.count.values().stream().mapToDouble(i -> i.intValue()).sum();
        if (y != Double.NaN) {
            xySerieSum.add(x, y);
        }
    }
    dataset.addSeries(xySerieSum);
    return dataset;
}

From source file:ai.susi.server.api.susi.SusiService.java

@Override
public JSONObject serviceImpl(Query post, HttpServletResponse response, Authorization user,
        final JsonObjectWithDefault permissions) throws APIException {

    // parameters
    String q = post.get("q", "").trim();
    int count = post.get("count", 1);
    int timezoneOffset = post.get("timezoneOffset", 0); // minutes, i.e. -60
    double latitude = post.get("latitude", Double.NaN); // i.e. 8.68 
    double longitude = post.get("longitude", Double.NaN); // i.e. 50.11
    String language = post.get("language", "en");
    try {/*w  w  w  .  ja va2  s .  c om*/
        DAO.susi.observe(); // get a database update
    } catch (IOException e) {
        DAO.log(e.getMessage());
    }

    // find out if we are dreaming
    SusiArgument observation_argument = new SusiArgument();
    List<SusiCognition> cognitions = DAO.susi.getMemories().getCognitions(user.getIdentity().getClient());
    cognitions.forEach(cognition -> observation_argument.think(cognition.recallDispute()));
    SusiThought recall = observation_argument.mindmeld(false);
    String etherpad_dream = recall.getObservation("_etherpad_dream");
    if (etherpad_dream != null && etherpad_dream.length() != 0) {
        // we are dreaming!
        // read the pad
        String etherpadApikey = DAO.getConfig("etherpad.apikey", "");
        String etherpadUrlstub = DAO.getConfig("etherpad.urlstub", "");
        String padurl = etherpadUrlstub + "/api/1/getText?apikey=" + etherpadApikey + "&padID=$query$";
        try {
            JSONTokener serviceResponse = new JSONTokener(
                    new ByteArrayInputStream(ConsoleService.loadData(padurl, etherpad_dream)));
            JSONObject json = new JSONObject(serviceResponse);
            String text = json.getJSONObject("data").getString("text");
            // fill an empty mind with the dream
            SusiMind dream = new SusiMind(null, null, DAO.susi_watch_dir); // an empty mind!
            JSONObject rules = dream.readSkills(new BufferedReader(new InputStreamReader(
                    new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8)));
            dream.learn(rules);
            // susi is now dreaming.. Try to find an answer out of the dream
            SusiCognition cognition = new SusiCognition(dream, q, timezoneOffset, latitude, longitude, count,
                    user.getIdentity());
            if (cognition.getAnswers().size() > 0) {
                DAO.susi.getMemories().addCognition(user.getIdentity().getClient(), cognition);
                return cognition.getJSON();
            }
        } catch (JSONException | IOException e) {
            e.printStackTrace();
        }
    }

    // answer normally
    SusiCognition cognition = new SusiCognition(DAO.susi, q, timezoneOffset, latitude, longitude, count,
            user.getIdentity());
    cognition.setLanguage(language);
    DAO.susi.getMemories().addCognition(user.getIdentity().getClient(), cognition);
    JSONObject json = cognition.getJSON();
    return json;
}

From source file:net.bioclipse.brunn.ui.editors.plateEditor.model.HillCurveIC50Calculator.java

public double calculateIC50(double[] conc, double[] si) {

    LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer();

    CurveFitter fitter = new CurveFitter(optimizer);

    for (int i = 0; i < si.length; i++) {
        fitter.addObservedPoint(conc[i], si[i] / 100);
        System.out.println("Added point: " + conc[i] + "; " + si[i] / 100);
    }//ww w . j  ava 2 s .c  om

    ParametricRealFunction function = new ParametricRealFunction() {

        @Override
        public double value(double c, double[] paramaters) throws FunctionEvaluationException {

            double d = paramaters[0];
            double n = paramaters[1];
            double c_pow_n = Math.pow(c, n);

            return c_pow_n / (c_pow_n + Math.pow(d, n));
        }

        @Override
        public double[] gradient(double c, double[] paramaters) throws FunctionEvaluationException {

            double d = paramaters[0];
            double n = paramaters[1];
            double c_pow_n = Math.pow(c, n);
            double d_pow_n = Math.pow(d, n);

            double ddd = -n * c_pow_n * Math.pow(d, n - 1) / Math.pow(c_pow_n + d_pow_n, 2);

            double ddn = (c_pow_n * d_pow_n * (Math.log(c) - Math.log(d))) / Math.pow(c_pow_n + d_pow_n, 2);

            return new double[] { ddd, ddn };
        }

    };

    double[] params = null;
    try {
        params = fitter.fit(function, new double[] { 1, 1 });
    } catch (Exception e) {
        Logger.getLogger(HillCurveIC50Calculator.class)
                .debug("Caught Exception while fitting dose response curve", e);
        return Double.NaN;
    }

    double d = params[0];
    double n = params[1];

    System.out.println("d=" + d);
    System.out.println("n=" + n);

    return Math.pow(-(0.5 - 1) * Math.pow(d, -n) / 0.5, -1 / n);
}

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

@Override
public double[] value(double[] point) throws IllegalArgumentException {
    List<Double> result = new ArrayList<>();

    for (int i = 0; i < parameters.size(); i++) {
        parser.setVarValue(parameters.get(i), point[i]);
    }//from  w  w w.  jav a  2s. c o m

    int n = variableValues.values().stream().findAny().get().size();

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

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

            result.add(Double.isFinite(value) ? value : Double.NaN);
        } catch (ParseException e) {
            e.printStackTrace();
            result.add(Double.NaN);
        }
    }

    return Doubles.toArray(result);
}

From source file:de.tudarmstadt.ukp.csniper.webapp.statistics.FleissKappaTest.java

@Ignore
@Test/*from  w w w .  j  ava2  s .  c  o m*/
public void testOneUser() {
    // nothing to compare - only one user
    test("c1", "type2", "user1", Double.NaN);
}

From source file:edu.cornell.med.icb.goby.algorithmic.algorithm.dmr.ChiSquareTestAdaptor.java

@Override
public double calculateNoCovariate(int... a) {
    final int cma = a[0];
    final int ca = a[1];
    final int cmb = a[2];
    final int cb = a[3];

    if (cma == 0 || ca == 0 || cmb == 0 || cb == 0) {
        setIgnorePair(true);/*from  w w  w.  j a  v  a2  s .c  o m*/
        return -StrictMath.log10(1.0);
    }
    expectedCounts[0] = cma;
    expectedCounts[1] = ca;
    observedCounts[0] = cmb;
    observedCounts[1] = cb;
    double pValue = Double.NaN;
    final ChiSquareTest chisquare = new ChiSquareTestImpl();
    try {
        final double pValueRaw = chisquare.chiSquareTest(expectedCounts, observedCounts);
        // math commons can return negative p-values?
        pValue = Math.abs(pValueRaw);
    } catch (MaxIterationsExceededException e) {

        LOG.error("expected:" + DoubleArrayList.wrap(expectedCounts).toString());
        LOG.error("observed:" + LongArrayList.wrap(observedCounts).toString());
        LOG.error(e);
        pValue = 1.0;
        setIgnorePair(true);
    } catch (MathException e) {
        e.printStackTrace();
        setIgnorePair(true);

    }

    setIgnorePair(false);
    return -StrictMath.log10(pValue);
}

From source file:com.bc.jexp.impl.DefaultNamespace.java

private void registerDefaultSymbols() {
    registerSymbol(SymbolFactory.createConstant("PI", Math.PI));
    registerSymbol(SymbolFactory.createConstant("E", Math.E));
    registerSymbol(SymbolFactory.createConstant("NaN", Double.NaN));
}