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.type.metric.functions.aggregations.Last.java

/**
 * Gets the last value in the time series.
 * It first orders the time series.//  ww w.  jav  a  2 s  .  c om
 *
 * @param timeSeries the time series
 * @return the average or 0 if the list is empty
 */
@Override
public void execute(MetricTimeSeries timeSeries, FunctionValueMap functionValueMap) {
    //If it is empty, we return NaN
    if (timeSeries.size() <= 0) {
        functionValueMap.add(this, Double.NaN);
        return;
    }

    //We need to sort the time series
    timeSeries.sort();
    functionValueMap.add(this, timeSeries.getValue(timeSeries.size() - 1));
}

From source file:de.qaware.chronix.solr.type.metric.functions.aggregations.First.java

/**
 * Gets the first value in the time series.
 * It first orders the time series./*from www .j a  v  a 2  s.c  o  m*/
 *
 * @param timeSeries the time series
 * @return the average or 0 if the list is empty
 */
@Override
public void execute(MetricTimeSeries timeSeries, FunctionValueMap functionValueMap) {
    //If it is empty, we return NaN
    if (timeSeries.size() <= 0) {
        functionValueMap.add(this, Double.NaN);
        return;
    }

    //we need to sort the time series
    timeSeries.sort();
    functionValueMap.add(this, timeSeries.getValue(0));
}

From source file:de.qaware.chronix.solr.type.metric.functions.aggregations.Sum.java

/**
 * Calculates the sum of the values of the given time series
 *
 * @param timeSeries the time series/*from   w  ww . ja  v  a 2 s .  com*/
 * @return the sum of the values
 */
@Override
public void execute(MetricTimeSeries timeSeries, FunctionValueMap functionValueMap) {
    //If it is empty, we return NaN
    if (timeSeries.size() <= 0) {
        functionValueMap.add(this, Double.NaN);
        return;
    }

    //Else calculate the analysis value
    int size = timeSeries.size();
    double sum = 0;
    //Sum up the single values
    for (int i = 1; i < size; i++) {
        sum += timeSeries.getValue(i);

    }
    //return it
    functionValueMap.add(this, sum);
}

From source file:de.qaware.chronix.solr.type.metric.functions.aggregations.StdDev.java

/**
 * Calculates the standard deviation of the first time series.
 *
 * @param timeSeries the time series/*from   w  w w .  ja  v  a  2s.c  o  m*/
 * @return the percentile or 0 if the list is empty
 */
@Override
public void execute(MetricTimeSeries timeSeries, FunctionValueMap functionValueMap) {
    //If it is empty, we return NaN
    if (timeSeries.size() <= 0) {
        functionValueMap.add(this, Double.NaN);
        return;
    }
    //Else calculate the analysis value
    functionValueMap.add(this,
            de.qaware.chronix.solr.type.metric.functions.math.StdDev.dev(timeSeries.getValues()));
}

From source file:de.qaware.chronix.solr.type.metric.functions.aggregations.Max.java

/**
 * Calculates the maximum value of the first time series.
 *
 * @param timeSeries the time series//from  w  w w .j  a  va 2s.  c o m
 * @return the maximum or 0 if the list is empty
 */
@Override
public void execute(MetricTimeSeries timeSeries, FunctionValueMap functionValueMap) {

    //If it is empty, we return NaN
    if (timeSeries.size() <= 0) {
        functionValueMap.add(this, Double.NaN);
        return;
    }
    //Else calculate the analysis value
    int size = timeSeries.size();
    double max = timeSeries.getValue(0);

    for (int i = 1; i < size; i++) {
        double next = timeSeries.getValue(i);
        if (next > max) {
            max = next;
        }
    }
    functionValueMap.add(this, max);
}

From source file:de.qaware.chronix.solr.type.metric.functions.aggregations.Min.java

/**
 * Calculates the minimum value of the first time series.
 *
 * @param timeSeries the time series for this analysis
 * @return the minimum or 0 if the list is empty
 *//*from  w w w.jav a2 s .  co  m*/
@Override
public void execute(MetricTimeSeries timeSeries, FunctionValueMap functionValueMap) {
    //If it is empty, we return NaN
    if (timeSeries.size() <= 0) {
        functionValueMap.add(this, Double.NaN);
        return;
    }

    //Else calculate the analysis value
    int size = timeSeries.size();
    double min = timeSeries.getValue(0);

    for (int i = 1; i < size; i++) {
        double next = timeSeries.getValue(i);
        if (next < min) {
            min = next;
        }
    }
    functionValueMap.add(this, min);
}

From source file:cloudnet.workloads.prediction.SimpleRegressionPredictionStrategy.java

@Override
public Long predictValue(long futureTimeStamp, long currTimeStamp, WorkloadHistory history) {
    Ensure.NotNull(history, "history");

    SimpleRegression r = new SimpleRegression();
    for (Map.Entry<Long, Long> entry : history.getWorkloadHistory().entrySet()) {
        r.addData(entry.getKey(), entry.getValue());
    }//from  w  w  w  . j  a  v  a  2 s .  c o  m

    double predicted = r.predict(futureTimeStamp);
    return predicted == Double.NaN || predicted < 0 ? null : (long) predicted;
}

From source file:de.qaware.chronix.solr.query.analysis.functions.aggregations.Sum.java

@Override
public double execute(MetricTimeSeries... args) {
    //Sum needs at least one time series
    if (args.length < 1) {
        throw new IllegalArgumentException("Sum aggregation needs at least one time series");
    }/* w  w  w. j  a  v a  2  s .  com*/

    //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
    int size = timeSeries.size();
    double sum = 0;
    //Sum up the single values
    for (int i = 1; i < size; i++) {
        sum += timeSeries.getValue(i);

    }
    //return it
    return sum;
}

From source file:com.cloudera.oryx.common.math.DoubleWeightedMean.java

@Override
public void clear() {
    count = 0;
    totalWeight = 0.0;
    mean = Double.NaN;
}

From source file:Float11.java

static public double asin(double x) {
    if (x < -1. || x > 1.)
        return Double.NaN;
    if (x == -1.)
        return -Math.PI / 2;
    if (x == 1)//from   w  ww .ja v  a2  s.  co m
        return Math.PI / 2;
    return atan(x / Math.sqrt(1 - x * x));
}