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:geogebra.util.MyMath.java
final public static double gamma(double x, Kernel kernel) { // Michael Borcherds 2008-05-04 if (x <= 0 && Kernel.isEqual(x, Math.round(x))) return Double.NaN; // negative integers // Michael Borcherds 2007-10-15 BEGIN added case for x<0 otherwise no // results in 3rd quadrant if (x >= 0) return Math.exp(Gamma.logGamma(x)); else/* w ww . j a v a2 s. c o m*/ return -Math.PI / (x * gamma(-x, kernel) * Math.sin(Math.PI * x)); // Michael Borcherds 2007-10-15 END }
From source file:de.thkwalter.et.schlupfbezifferung.Betriebspunkt.java
/** * Dieser Konstruktor initialisiert die komplexe Stnderstromstrke (in A) * //from w w w .j a v a 2 s. c om * @param i_1x Die x-Komponente der komplexen Stnderstromstrke (in A; das Negative des Imaginrteils) * @param i_1y Die y-Komponente der komplexen Stnderstromstrke (in A; der Realteil) */ public Betriebspunkt(double i_1x, double i_1y) { // Die komplexe Stnderstromstrke (in A) wird initialisiert. this.i_1 = new Complex(i_1y, -i_1x); // Der Schlupf wird initialisiert. this.s = Double.NaN; }
From source file:com.itemanalysis.psychometrics.reliability.AbstractScoreReliability.java
public double[] confidenceInterval() { double numberOfExaminees = matrix.getMaxSampleSize(); double[] confidenceInterval = new double[2]; double numberOfItems = (double) nItems; double df1 = numberOfExaminees - 1.0; double df2 = (numberOfExaminees - 1.0) * (numberOfItems - 1.0); FDistribution fDist = new FDistribution(df1, df2); try {// www . j ava 2 s.c o m confidenceInterval[0] = 1.0 - ((1.0 - this.value()) * fDist.inverseCumulativeProbability(0.975)); confidenceInterval[1] = 1.0 - ((1.0 - this.value()) * fDist.inverseCumulativeProbability(0.025)); } catch (Exception ex) { confidenceInterval[0] = Double.NaN; confidenceInterval[1] = Double.NaN; } return confidenceInterval; }
From source file:beast.math.distributions.BetaDistribution.java
/** * This general constructor creates a new beta distribution with a * specified mean and scale/*from ww w. j av a 2 s .c o m*/ * * @param alpha shape parameter * @param beta shape parameter */ public BetaDistribution(double alpha, double beta) { this.alpha = alpha; this.beta = beta; z = Double.NaN; solverAbsoluteAccuracy = DEFAULT_INVERSE_ABSOLUTE_ACCURACY; }
From source file:de.qaware.chronix.solr.query.analysis.functions.aggregations.SignedDifference.java
/** * Calculate the difference between the first and the last value of a given time series * * @param args the time series/*ww w. ja v a2 s. c o 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("Signed difference 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(); //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) { return last - first; } //both value are positive if (first > 0 && last > 0) { return last - first; } //start is negative and end is positive if (first < 0 && last > 0) { return last - first; } //start is positive and end is negative return last - first; }
From source file:edu.anu.spice.Evaluation.java
protected void calcFScore(boolean allowNan) { double beta = 1.0; int ref_n = this.fn + this.tp; int test_n = this.fp + this.tp; if (ref_n > 0) { this.re = (double) tp / (double) ref_n; if (test_n > 0) { this.pr = (double) tp / (double) test_n; }//ww w .ja v a 2 s . c om if (this.pr > 0 && this.re > 0) { this.f = (1.0 + beta * beta) * (this.pr * this.re) / (beta * beta * this.pr + this.re); } } if (allowNan && ref_n == 0) { this.f = Double.NaN; this.pr = Double.NaN; this.re = Double.NaN; } }
From source file:mase.app.allocation.AllocationProblem.java
@Override public void setup(EvolutionState state, Parameter base) { super.setup(state, base); ParamUtils.autoSetParameters(this, state, base, defaultBase(), false); nulify = new double[numAgents]; Arrays.fill(nulify, Double.NaN); dimensions = state.parameters.getInt(new Parameter("vector.species.genome-size"), null); // calculate types, if not given if (uniqueTypes == null) { int div = numAgents / numUniqueTypes; int rem = numAgents % numUniqueTypes; uniqueTypes = new int[numUniqueTypes]; for (int i = 0; i < numUniqueTypes; i++) { uniqueTypes[i] = div;/*from w w w .ja v a 2 s.c o m*/ if (rem > 0) { uniqueTypes[i]++; rem--; } } } else { state.output.warning("Overriding numTypes with the given types"); } // validate simulation parameters int checkSum = 0; for (int t : uniqueTypes) { checkSum += t; } if (checkSum != numAgents) { state.output .fatal("Optimal allocation " + checkSum + " does not match the number of agents " + numAgents); } if (numClusters > 0 && (clusterSize < 0 || clusterSize > 1)) { state.output.fatal("Invalid cluster size [0,1]: " + clusterSize); } if (minSeparation == -1) { minSeparation = FastMath.sqrt(dimensions) / 3; state.output.warning("Using default min separation sqrt(dimensions)/3: " + minSeparation); } // randomly create target points Random rand = new Random((int) state.job[0]); double[][] unique = new double[uniqueTypes.length][]; if (numClusters == 0) { double[] min = new double[dimensions], max = new double[dimensions]; Arrays.fill(min, 0); Arrays.fill(max, 1); unique = generateDispersedPoints(rand, uniqueTypes.length, minSeparation, min, max); } else { double[] min = new double[dimensions], max = new double[dimensions]; Arrays.fill(min, clusterSize / 2); Arrays.fill(max, 1 - clusterSize / 2); double[][] centers = generateDispersedPoints(rand, numClusters, minSeparation, min, max); int perCluster = uniqueTypes.length / numClusters; int remaining = uniqueTypes.length % numClusters; for (int i = 0; i < centers.length; i++) { for (int j = 0; j < dimensions; j++) { min[j] = centers[i][j] - clusterSize / 2; max[j] = centers[i][j] + clusterSize / 2; } int size = perCluster; if (remaining > 0) { size++; remaining--; } double[][] generated = generateDispersedPoints(rand, size, 0, min, max); System.arraycopy(generated, 0, unique, i * perCluster, generated.length); } } types = new double[numAgents][]; int index = 0; for (int i = 0; i < unique.length; i++) { for (int j = 0; j < uniqueTypes[i]; j++) { types[index++] = unique[i]; } } // debug: print types for (int i = 0; i < types.length; i++) { System.out.println(i + ": " + Arrays.toString(types[i])); } System.out.print(" "); for (int i = 0; i < types.length; i++) { System.out.printf("%6d", i); } System.out.println(); for (int i = 0; i < types.length; i++) { System.out.printf("%2d", i); for (int j = 0; j < types.length; j++) { System.out.printf(" %.3f", DIST.compute(types[i], types[j])); } System.out.println(); } }
From source file:com.codahale.metrics.TestMergeableExponentiallyDecayingReservoir.java
@Test public void testEmptyReservoir() { MergeableExponentiallyDecayingReservoir res = new MergeableExponentiallyDecayingReservoir(10, 0.015); // add NO data double[] dataValues = res.getUnsortedValues(); assertEquals("expected empty dataValues array", 0, dataValues.length); double result = StatUtils.percentile(dataValues, 50.0); assertEquals("expected NaN for 50th percentile of empty array", Double.NaN, result); result = StatUtils.max(dataValues);/*from ww w. j a v a 2 s .com*/ assertEquals("expected NaN for max of empty array", Double.NaN, result); }
From source file:org.sloth.validation.CoordinateValidator.java
@Override public void validate(Object t, Errors e) { Coordinate c = (Coordinate) t;//from w w w . j a v a 2s . com double lon = c.getLongitude(), lat = c.getLatitude(); if (lon > 180.0 || lon < -180.0) { e.rejectValue("longitude", INVALID_LONGITUDE); } if (lat > 180.0 || lat < -180.0 || lat == Double.NaN) { e.rejectValue("latitude", INVALID_LATITUDE); } if (Double.isNaN(lat)) { e.rejectValue("latitude", EMPTY_LATITUDE); } if (Double.isNaN(lon)) { e.rejectValue("longitude", EMPTY_LONGITUDE); } }
From source file:iDynoOptimizer.MOEAFramework26.src.org.moeaframework.core.variable.RealVariable.java
/** * Constructs a real variable in the range {@code lowerBound <= x <= * upperBound} with an uninitialized value. * //from ww w . j a v a 2 s . c om * @param lowerBound the lower bound of this decision variable, inclusive * @param upperBound the upper bound of this decision variable, inclusive */ public RealVariable(double lowerBound, double upperBound) { this(Double.NaN, lowerBound, upperBound); }