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:com.itemanalysis.psychometrics.measurement.ClassicalItemStatistics.java

public double getDindexUpper() {
    if (dIndex) {
        return upper.getResult();
    } else {//from w w  w  . j a v  a 2 s .c  o  m
        return Double.NaN;
    }
}

From source file:com.bt.aloha.sipstone.GenGraph.java

private List<Double> splitData(String line) {
    String[] data = line.split(",");
    List<Double> dData = new Vector<Double>();
    for (String d : data) {
        if (d.contains(":"))
            dData.add(getTimeAsLong(d));
        else// w w  w .j a  v a  2  s  .  c  o  m
            try {
                dData.add(Double.parseDouble(d));
            } catch (NumberFormatException nfe) {
                dData.add(Double.NaN);
            }
    }
    return dData;
}

From source file:mlflex.helper.MathUtilities.java

/** Identifies the maximum numeric value in a list.
 *
 * @param values Numeric values to test/*from w w w  .ja  va2 s.  c  o  m*/
 * @return Maximum value
 * @throws Exception
 */
public static double Max(ArrayList<Double> values) throws Exception {
    ArrayList<Double> values2 = new ArrayList<Double>();
    for (Double value : values)
        if (!value.equals(Double.NaN))
            values2.add(value);

    if (values2.size() == 0)
        throw new Exception("The list was empty, so Max could not be determined.");

    int indexOfMax = 0;

    for (int i = 1; i < values2.size(); i++) {
        Double value = values2.get(i);

        if (value > values2.get(indexOfMax))
            indexOfMax = i;
    }

    return values2.get(indexOfMax);
}

From source file:dr.math.distributions.BetaDistribution.java

/**
 * the natural log of the probability density function of the distribution
 *
 * @param x argument//from  ww w  . j  a v a 2s.  c  o m
 * @return log pdf value
 */
public double logPdf(double x) {
    recomputeZ();
    if (x < 0 || x > 1) {
        return Double.NEGATIVE_INFINITY;
    } else if (x == 0) {
        if (alpha < 1) {
            // AR - throwing exceptions deep in numerical code causes trouble. Catching runtime
            // exceptions is bad. Better to return NaN and let the calling code deal with it.
            return Double.NaN;
            //                throw MathRuntimeException.createIllegalArgumentException(
            //                        "Cannot compute beta density at 0 when alpha = {0,number}", alpha);
        }
        if (alpha == 1) {
            return 0;
        }
        return Double.NEGATIVE_INFINITY;
    } else if (x == 1) {
        if (beta < 1) {
            // AR - throwing exceptions deep in numerical code causes trouble. Catching runtime
            // exceptions is bad. Better to return NaN and let the calling code deal with it.
            return Double.NaN;
            //                throw MathRuntimeException.createIllegalArgumentException(
            //                        "Cannot compute beta density at 1 when beta = %.3g", beta);
        }
        if (beta == 1) {
            return 0;
        }
        return Double.NEGATIVE_INFINITY;
    } else {
        double logX = Math.log(x);
        double log1mX = Math.log1p(-x);
        return (alpha - 1) * logX + (beta - 1) * log1mX - z;
    }
}

From source file:delfos.group.results.groupevaluationmeasures.MAE_byMemberStdDev.java

@Override
public GroupEvaluationMeasureResult getMeasureResult(GroupRecommenderSystemResult groupRecommenderSystemResult,
        DatasetLoader<? extends Rating> originalDatasetLoader, RelevanceCriteria relevanceCriteria,
        DatasetLoader<? extends Rating> trainingDatasetLoader,
        DatasetLoader<? extends Rating> testDatasetLoader) {

    TreeMap<Integer, MeanIterative> maeAllMembers = new TreeMap<>();

    for (GroupOfUsers groupOfUsers : groupRecommenderSystemResult.getGroupsOfUsers()) {
        Collection<Recommendation> groupRecommendations = groupRecommenderSystemResult
                .getGroupOutput(groupOfUsers).getRecommendations().getRecommendations();

        if (groupRecommendations.isEmpty()) {
            continue;
        }/*w ww .java  2s  .c  o m*/
        MeanIterative maeGroup = new MeanIterative();
        Map<Integer, MeanIterative> maeMembers = new TreeMap<>();
        for (User member : groupOfUsers.getMembers()) {
            maeMembers.put(member.getId(), new MeanIterative());
        }

        Map<Integer, Map<Integer, ? extends Rating>> groupTrueRatings = new TreeMap<>();

        groupOfUsers.getIdMembers().stream().forEach((idUser) -> {
            try {
                groupTrueRatings.put(idUser, testDatasetLoader.getRatingsDataset().getUserRatingsRated(idUser));
            } catch (UserNotFound ex) {
                ERROR_CODES.USER_NOT_FOUND.exit(ex);
            }
        });

        for (Recommendation recommendation : groupRecommendations) {
            if (Double.isNaN(recommendation.getPreference().doubleValue())) {
                continue;
            }
            int idItem = recommendation.getItem().getId();
            for (int idUser : groupOfUsers.getIdMembers()) {
                if (groupTrueRatings.get(idUser).containsKey(idItem)) {
                    double trueRating = groupTrueRatings.get(idUser).get(idItem).getRatingValue().doubleValue();
                    double predicted = recommendation.getPreference().doubleValue();
                    double absoluteError = Math.abs(predicted - trueRating);

                    maeGroup.addValue(absoluteError);
                    maeMembers.get(idUser).addValue(absoluteError);
                }
            }
        }

        maeAllMembers.putAll(maeMembers);

    }

    double[] maeByMember = maeAllMembers.values().parallelStream()
            .mapToDouble(meanMember -> meanMember.getMean()).filter(value -> !Double.isNaN(value)).toArray();

    double maeByMemberStdDev = new StandardDeviation().evaluate(maeByMember);

    if (maeByMember.length == 0) {
        return new GroupEvaluationMeasureResult(this, Double.NaN);
    } else {
        return new GroupEvaluationMeasureResult(this, maeByMemberStdDev);
    }
}

From source file:com.ichi2.libanki.Card.java

public Card(Collection col, Long id) {
    mCol = col;/*from   ww w.  ja  v  a  2s. c  o m*/
    mTimerStarted = Double.NaN;
    mQA = null;
    mNote = null;
    if (id != null) {
        mId = id;
        load();
    } else {
        // to flush, set nid, ord, and due
        mId = Utils.timestampID(mCol.getDb(), "cards");
        mDid = 1;
        mType = 0;
        mQueue = 0;
        mIvl = 0;
        mFactor = 0;
        mReps = 0;
        mLapses = 0;
        mLeft = 0;
        mODue = 0;
        mODid = 0;
        mFlags = 0;
        mData = "";
    }
}

From source file:com.idylwood.utils.MathUtils.java

public final static double min(double... values) {
    if (values.length == 0)
        return Double.NaN;
    double ret = values[0];
    for (int i = 1; i < values.length; i++)
        if (values[i] < ret)
            ret = values[i];/*  w  w  w.  j a  v a2  s. c  om*/
    return ret;
}

From source file:com.cloudera.oryx.kmeans.computation.local.Standardize.java

private static double asDouble(String token) {
    try {//  w ww.j a v a  2s .co m
        return Double.parseDouble(token);
    } catch (NumberFormatException e) {
        log.warn("Invalid numeric token: {}", token);
        return Double.NaN;
    }
}

From source file:org.ulyssis.ipp.snapshot.TeamState.java

public TeamState() {
    this.lastTagSeenEvent = Optional.empty();
    this.tagFragmentCount = 0;
    this.speed = Double.NaN;
    this.predictedSpeed = Double.NaN;
}

From source file:gedi.util.math.stat.distributions.PoissonBinomial.java

@Override
public double density(double x, boolean log) {
    if (pp.length > 2000)
        return normalApprox.density(x + 0.5, log);
    if (MathFunctions.isNonInt(x))
        return Double.NaN;
    if (x < 0 || x >= z.length)
        return 0;
    double re = Math.max(0, z[(int) x].getReal() / m);
    if (log)//from   w w  w.  ja v  a2s .com
        re = Math.log(re);
    return re;
}