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:de.qaware.chronix.solr.query.analysis.functions.aggregations.Percentile.java

/**
 * Calculates the percentile of the first time series.
 *
 * @param args the time series/*from   w  w  w.  j a v  a 2s . co  m*/
 * @return the percentile or 0 if the list is empty
 */
@Override
public double execute(MetricTimeSeries... args) {
    //Sum needs at least one time series
    if (args.length < 1) {
        throw new IllegalArgumentException("Percentile aggregation needs at least one time series");
    }
    //Took the first time series
    MetricTimeSeries timeSeries = args[0];

    //If it is empty, we return NaN
    if (timeSeries.size() <= 0) {
        return Double.NaN;
    }

    //Else calculate the analysis value
    return de.qaware.chronix.solr.query.analysis.functions.math.Percentile.evaluate(timeSeries.getValues(),
            percentile);
}

From source file:com.itemanalysis.psychometrics.reliability.ReliabilityInterval.java

public double[] confidenceInterval() {
    double N = sampleSize;
    double nI = numberOfVariables;
    double df1 = N - 1.0;
    double df2 = (N - 1.0) * (nI - 1.0);
    double[] ci = new double[2];
    FDistribution fDist = new FDistribution(df1, df2);
    try {//from w w w.j  a  v a 2 s  .c  o  m
        ci[0] = 1.0 - ((1.0 - reliability.value()) * fDist.inverseCumulativeProbability(0.975));
        ci[1] = 1.0 - ((1.0 - reliability.value()) * fDist.inverseCumulativeProbability(0.025));
    } catch (Exception ex) {
        ci[0] = Double.NaN;
        ci[1] = Double.NaN;
    }

    return ci;
}

From source file:de.tor.tribes.util.BuildingSettings.java

public static boolean loadSettings(String pServerID) {
    Arrays.fill(MAX_LEVEL, -1);//  w w w.j a  v a 2 s.  c om
    Arrays.fill(MIN_LEVEL, -1);

    Arrays.fill(BUILD_WOOD, -1);
    Arrays.fill(BUILD_STONE, -1);
    Arrays.fill(BUILD_IRON, -1);
    Arrays.fill(BUILD_POP, -1);
    Arrays.fill(BUILD_TIME, -1);
    Arrays.fill(BUILD_WOOD_FACTOR, Double.NaN);
    Arrays.fill(BUILD_STONE_FACTOR, Double.NaN);
    Arrays.fill(BUILD_IRON_FACTOR, Double.NaN);
    Arrays.fill(BUILD_POP_FACTOR, Double.NaN);
    Arrays.fill(BUILD_TIME_FACTOR, Double.NaN);

    try {
        logger.debug("Loading server buildings");
        String buildingsPath = Constants.SERVER_DIR + "/" + pServerID + "/buildings.xml";

        logger.debug("Parse buildings from '" + buildingsPath + "'");
        Document d = JDomUtils.getDocument(new File(buildingsPath));

        for (Element b : d.getRootElement().getChildren()) {
            String name = b.getName();
            int index = ArrayUtils.indexOf(BUILDING_NAMES, name);

            if (index < 0) {
                logger.warn("Found unknown Building {}", name);
                continue;
            }

            try {
                MAX_LEVEL[index] = Integer.parseInt(b.getChildTextTrim("max_level"));
                MIN_LEVEL[index] = Integer.parseInt(b.getChildTextTrim("min_level"));

                BUILD_WOOD[index] = Integer.parseInt(b.getChildTextTrim("wood"));
                BUILD_STONE[index] = Integer.parseInt(b.getChildTextTrim("stone"));
                BUILD_IRON[index] = Integer.parseInt(b.getChildTextTrim("iron"));
                BUILD_POP[index] = Integer.parseInt(b.getChildTextTrim("pop"));
                BUILD_TIME[index] = Integer.parseInt(b.getChildTextTrim("build_time"));
                BUILD_WOOD_FACTOR[index] = Double.parseDouble(b.getChildTextTrim("wood_factor"));
                BUILD_STONE_FACTOR[index] = Double.parseDouble(b.getChildTextTrim("stone_factor"));
                BUILD_IRON_FACTOR[index] = Double.parseDouble(b.getChildTextTrim("iron_factor"));
                BUILD_POP_FACTOR[index] = Double.parseDouble(b.getChildTextTrim("pop_factor"));
                BUILD_TIME_FACTOR[index] = Double.parseDouble(b.getChildTextTrim("build_time_factor"));
            } catch (Exception e) {
                logger.error("Got an excetion during reading of buildings", e);
            }
        }
    } catch (Exception e) {
        logger.error("Failed to load buildings", e);
        return false;
    }
    logger.info(Arrays.toString(MAX_LEVEL));
    logger.info(Arrays.toString(MIN_LEVEL));
    logger.info(Arrays.toString(BUILD_WOOD));
    logger.info(Arrays.toString(BUILD_STONE));
    logger.info(Arrays.toString(BUILD_IRON));
    logger.info(Arrays.toString(BUILD_POP));
    logger.info(Arrays.toString(BUILD_TIME));
    logger.info(Arrays.toString(BUILD_WOOD_FACTOR));
    logger.info(Arrays.toString(BUILD_STONE_FACTOR));
    logger.info(Arrays.toString(BUILD_IRON_FACTOR));
    logger.info(Arrays.toString(BUILD_POP_FACTOR));
    logger.info(Arrays.toString(BUILD_TIME_FACTOR));
    logger.debug("Successfully read buildings for server '" + pServerID + "'");
    return true;
}

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

@SuppressWarnings("UnusedDeclaration")
public void setAlpha(double alpha) {
    this.alpha = alpha;
    dof = Double.NaN;
    scale = Double.NaN;//from   ww w  .  ja v a2  s . c o m
    init();
}

From source file:com.joptimizer.functions.SOCPLogarithmicBarrier.java

public double value(double[] X) {
    RealVector x = new ArrayRealVector(X);

    double ret = 0;
    for (int i = 0; i < socpConstraintParametersList.size(); i++) {
        SOCPConstraintParameters param = socpConstraintParametersList.get(i);
        double t = this.buildT(param, x);
        if (t < 0) {
            return Double.NaN;
        }/* www.  j  a  v a  2 s . c  o  m*/
        RealVector u = this.buildU(param, x);
        double t2uu = t * t - u.dotProduct(u);
        if (t2uu <= 0) {
            return Double.NaN;
        }
        double ret_i = -Math.log(t2uu);
        ret += ret_i;
    }

    return ret;
}

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

public static double[] getFunctionPoints(Map<String, Double> parserConstants, String formula, String varX,
        double[] valuesX) throws ParseException {
    FunctionConf function = new FunctionConf(parserConstants, formula, varX, valuesX);
    double[] result = results.getIfPresent(function);

    if (result != null) {
        return result;
    }//from  w w  w  . j av a 2  s. co m

    Parser parser = new Parser();

    parserConstants.forEach((constant, value) -> parser.setVarValue(constant, value));

    ASTNode f = parser.parse(formula);
    double[] valuesY = new double[valuesX.length];

    Arrays.fill(valuesY, Double.NaN);

    for (int i = 0; i < valuesX.length; i++) {
        parser.setVarValue(varX, valuesX[i]);
        valuesY[i] = parser.evaluate(f);
    }

    results.put(function, valuesY);

    return valuesY;
}

From source file:net.recommenders.rival.evaluation.statistics.StatisticalSignificance.java

/**
 * Gets the p-value according to the requested method.
 *
 * @param method one of "t", "pairedT", "wilcoxon"
 * @return the p-value according to the requested method
 *//*from   ww  w .  j  a v a  2s .  c  o  m*/
public double getPValue(final String method) {
    double p = Double.NaN;

    double[] baselineValues = new double[baselineMetricPerDimension.values().size()];
    int i = 0;
    for (Double d : baselineMetricPerDimension.values()) {
        baselineValues[i] = d;
        i++;
    }

    double[] testValues = new double[testMetricPerDimension.values().size()];
    i = 0;
    for (Double d : testMetricPerDimension.values()) {
        testValues[i] = d;
        i++;
    }

    if ("t".equals(method)) {
        p = TestUtils.tTest(baselineValues, testValues);
    } else if ("pairedT".equals(method)) {
        p = TestUtils.pairedTTest(baselineValues, testValues);
    } else if ("wilcoxon".equals(method)) {
        p = new WilcoxonSignedRankTest().wilcoxonSignedRankTest(baselineValues, testValues, false);
    }

    return p;
}

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

@Override
protected double compute(double value1, double value2) {

    // special case for handling missing values
    if (Double.isNaN(value1) || Double.isNaN(value2)) {
        return Double.NaN;
    }//from   www . j  av a 2  s .c om

    if (value1 < 0 || value2 < 0) {
        throw new FunctionInputException("expression_parser.function_non_negative", getFunctionName());
    }
    // This is the common definition for the case for k > n.
    if (value2 > value1) {
        return 0;
    } else {
        return CombinatoricsUtils.binomialCoefficientDouble((int) value1, (int) value2);
    }
}

From source file:geogebra.kernel.AlgoRootInterval.java

final double calcRoot() {
    if (!(f.isDefined() && aGeo.isDefined() && bGeo.isDefined()))
        return Double.NaN;

    double root = Double.NaN;
    Function fun = f.getFunction();

    if (rootFinder == null) {
        UnivariateRealSolverFactory fact = UnivariateRealSolverFactory.newInstance();
        rootFinder = fact.newBrentSolver();
    }//w  ww.j av a 2s .c  o  m

    try {
        // Brent's method
        root = rootFinder.solve(new RealRootAdapter(fun), a.getDouble(), b.getDouble());
    } catch (Exception e) {
        try {
            // Let's try again by searchin for a valid domain first
            double[] borders = RealRootUtil.getDefinedInterval(fun, a.getDouble(), b.getDouble());
            root = rootFinder.solve(new RealRootAdapter(fun), borders[0], borders[1]);
        } catch (Exception ex) {
            root = Double.NaN;
        }
    }

    // check result
    if (Math.abs(fun.evaluate(root)) < Kernel.MIN_PRECISION)
        return root;
    else
        return Double.NaN;
}

From source file:ml.shifu.shifu.core.binning.MunroPatBinning.java

/**
 * set min/max, merge same bins// w ww . j  av  a 2s.c  om
 * In a very skewed data array, this one may not be well performed
 * 
 * @param bins
 *            input bins
 * @return merged bins
 */
private List<Double> binMerge(List<Double> bins) {
    List<Double> newBins = new ArrayList<Double>();
    if (bins.size() == 0) {
        bins.add(Double.NaN);
        return bins;
    }

    Double cur = bins.get(0);
    newBins.add(cur);

    int i = 1;
    while (i < bins.size()) {
        if (Math.abs(cur - bins.get(i)) > 1e-10) {
            newBins.add(bins.get(i));
        }
        cur = bins.get(i);
        i++;
    }

    if (newBins.size() == 1) {
        // special case since there is only 1 candidate in the bins
        double val = newBins.get(0);
        newBins = Arrays.asList(new Double[] { Double.NEGATIVE_INFINITY, val });
    } else if (newBins.size() == 2) {
        newBins.set(0, Double.NEGATIVE_INFINITY);
    } else {
        newBins.set(0, Double.NEGATIVE_INFINITY);
        // remove the max, and became open interval
        newBins.remove(newBins.size() - 1);
    }
    return newBins;
}