List of usage examples for java.lang Double NaN
double NaN
To view the source code for java.lang Double NaN.
Click Source Link
From source file:de.qaware.chronix.solr.query.analysis.functions.aggregations.Avg.java
/** * Calculates the average value of the first time series. * * @param args the time series/*w ww .ja v a 2s. co m*/ * @return the average 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("Avg 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 int size = timeSeries.size(); double current = 0; for (int i = 0; i < size; i++) { current += timeSeries.getValue(i); } return current / timeSeries.size(); }
From source file:de.qaware.chronix.solr.type.metric.functions.aggregations.SignedDifference.java
/** * Calculate the difference between the first and the last value of a given time series * * @param timeSeries the time series//w w w .jav a 2s . co m * @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(); //get the first and the last value double first = timeSeries.getValue(0); double last = timeSeries.getValue(timeSeries.size() - 1); //both values are negative if (first < 0 && last < 0) { functionValueMap.add(this, last - first); return; } //both value are positive if (first > 0 && last > 0) { functionValueMap.add(this, last - first); return; } //start is negative and end is positive if (first < 0 && last > 0) { functionValueMap.add(this, last - first); return; } //start is positive and end is negative functionValueMap.add(this, last - first); }
From source file:de.qaware.chronix.solr.query.analysis.functions.aggregations.Last.java
/** * Gets the last value in the time series. * It first orders the time series./*from w w w .ja va 2s. co m*/ * * @param args the time series * @return the average 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("Last function 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; } //We need to sort the time series timeSeries.sort(); return timeSeries.getValue(timeSeries.size() - 1); }
From source file:de.qaware.chronix.solr.query.analysis.functions.aggregations.First.java
/** * Gets the first value in the time series. * It first orders the time series.//from w ww . ja va 2s . c o m * * @param args the time series * @return the average 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("First function 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; } //we need to sort the time series timeSeries.sort(); return timeSeries.getValue(0); }
From source file:de.qaware.chronix.solr.query.analysis.functions.aggregations.Max.java
/** * Calculates the maximum value of the first time series. * * @param args the time series// w w w .j av a 2 s . c o m * @return the maximum 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("Max 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 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; } } return max; }
From source file:de.qaware.chronix.solr.query.analysis.functions.aggregations.StdDev.java
/** * Calculates the standard deviation of the first time series. * * @param args the time series// www . j av a 2 s. 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("Standard deviation 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.StdDev.dev(timeSeries.getValues()); }
From source file:de.qaware.chronix.solr.query.analysis.functions.aggregations.Min.java
/** * Calculates the minimum value of the first time series. * * @param args the time series for this analysis * @return the minimum or 0 if the list is empty *///from w w w . ja v a 2 s . c om @Override public double execute(MetricTimeSeries... args) { //Sum needs at least one time series if (args.length < 1) { throw new IllegalArgumentException("Min 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 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; } } return min; }
From source file:ch.zweivelo.renderer.simple.math.RayTest.java
@Test public void testIsValidT() throws Exception { assertTrue(ray.isValidT(EPSILON));/* www .j ava 2 s . c o m*/ assertTrue(ray.isValidT(1d)); assertTrue(ray.isValidT(10d)); assertTrue(ray.isValidT(100d)); assertTrue(ray.isValidT(1000d)); assertTrue(ray.isValidT(EPSIPON_MAX)); assertFalse(ray.isValidT(0d)); assertFalse(ray.isValidT(-1d)); assertFalse(ray.isValidT(-100000d)); assertFalse(ray.isValidT(Double.NaN)); assertFalse(ray.isValidT(Double.POSITIVE_INFINITY)); assertFalse(ray.isValidT(Double.NEGATIVE_INFINITY)); }
From source file:org.hawkular.alerts.api.model.condition.RateConditionEval.java
/** * Used for JSON deserialization, not for general use. *///from w ww . ja va 2 s . c o m public RateConditionEval() { super(Type.RATE, false, 0, null); this.value = Double.NaN; this.previousValue = Double.NaN; this.time = 0L; this.previousTime = 0L; this.rate = Double.NaN; }
From source file:mlflex.helper.MathUtilities.java
/** Divides one number by another. If the denominator is zero, it returns Double.NaN (not a number). * * @param numerator Numerator value/*from w ww. jav a 2 s . com*/ * @param denominator Denominator value * @return Divided number */ public static double SmartDivide(double numerator, double denominator) { if (denominator == 0.0) return Double.NaN; return numerator / denominator; }