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:com.leonarduk.finance.chart.PieChartFactory.java
public PieChartFactory add(final String name, final Double double1) { if (double1.equals(Double.NaN)) { return this; }//from www. ja v a 2s . c o m if (this.dataset.getKeys().contains(name)) { final Double value = this.dataset.getValue(name).doubleValue(); this.put(name, double1 + value); } else { this.put(name, double1); } return this; }
From source file:geogebra.util.MyMath.java
final public static double betaIncompleteRegularized(double a, double b, double x) { try {/*from w w w .j a v a 2s . co m*/ return Beta.regularizedBeta(x, a, b); } catch (MathException e) { return Double.NaN; } }
From source file:net.relet.freimap.NodeInfo.java
public void setLinkCountProfile(LinkedList<LinkCount> lcp) { if (lcp.size() == 0) { minLinks = 0;/* w w w . j a va2s .c o m*/ maxLinks = 0; return; } XYSeries data = new XYSeries("links"); XYSeries avail = new XYSeries("avail"); XYSeriesCollection datac = new XYSeriesCollection(data); datac.addSeries(avail); linkCountChart = ChartFactory.createXYLineChart("average incoming link count\r\nincoming link availability", "time", "count", datac, PlotOrientation.VERTICAL, false, false, false); sexupLayout(linkCountChart); long first = lcp.getFirst().time, last = lcp.getLast().time, lastClock = first, count = 0, maxCount = 0; long aggregate = (last - first) / CHART_WIDTH; double sum = 0; /* ok, this ain't effective, we do it just to pre-calculate maxCount */ ListIterator<LinkCount> li = lcp.listIterator(); while (li.hasNext()) { LinkCount lc = li.next(); count++; if (lc.time - lastClock > aggregate) { if (maxCount < count) maxCount = count; lastClock = lc.time; count = 0; } } //reset for second iteration count = 0; lastClock = first; //iterate again li = lcp.listIterator(); while (li.hasNext()) { LinkCount lc = li.next(); if (minLinks > lc.count) minLinks = lc.count; if (maxLinks < lc.count) maxLinks = lc.count; sum += lc.count; count++; if (aggregate == 0) aggregate = 1000;//dirty hack if (lc.time - lastClock > aggregate) { for (long i = lastClock; i < lc.time - aggregate; i += aggregate) { data.add(i * 1000, (i == lastClock) ? sum / count : Double.NaN); avail.add(i * 1000, (i == lastClock) ? ((double) count / maxCount) : 0); } count = 0; sum = 0; lastClock = lc.time; } } status = STATUS_AVAILABLE; }
From source file:fr.ens.transcriptome.teolenn.util.MathUtils.java
/** * Calc the mean of an array of double// ww w .j ava2 s.co m * @param data Data * @return the mean or NaN if the data is null */ public static double mean(final double[] data) { if (data == null) return Double.NaN; int count = 0; float sum = 0; for (int i = 0; i < data.length; i++) { count++; sum += data[i]; } return sum / count; }
From source file:gedi.util.math.stat.testing.OneWayAnova.java
public double getPvalue() { FDistribution fdist = new FDistribution(getFactorDof(), getErrorDof()); if (getFactorDof() < 1 || getErrorDof() < 1) return Double.NaN; return 1 - fdist.cumulativeProbability(getFStatistic()); }
From source file:edu.anu.spice.SpiceStats.java
private Evaluation macroAverage(String filter) { Evaluation result = new Evaluation(); int imageCount = 0; for (Map<String, Evaluation> score : this.scores) { Evaluation s = score.get(filter); result.tp += s.tp;//from w w w.j a va 2 s . co m result.fp += s.fp; result.fn += s.fn; if (!Double.isNaN(s.f) && !Double.isNaN(s.pr) && !Double.isNaN(s.re)) { result.f += s.f; result.pr += s.pr; result.re += s.re; imageCount += 1; } } if (imageCount > 0) { result.f /= (double) imageCount; result.pr /= (double) imageCount; result.re /= (double) imageCount; result.numImages = imageCount; } else { result.f = Double.NaN; result.pr = Double.NaN; result.re = Double.NaN; result.numImages = 0; } return result; }
From source file:com.cti.vpx.controls.graph.utilities.ui.graphs.waterfallGraph.Variance.java
/** * Create a FirstMoment instance */ public Variance() { n = 0; m1 = Double.NaN; dev = Double.NaN; nDev = Double.NaN; m2 = Double.NaN; }
From source file:com.clust4j.algo.preprocess.ImputationTests.java
@Test public void testMedianImputation2() { final double[][] d = new double[][] { new double[] { Double.NaN, 1, 2 }, new double[] { 1, Double.NaN, 3 }, new double[] { 2, 2, 1 }, new double[] { 3, 5, Double.NaN } }; final MedianImputation median = new MedianImputation(new MedianImputationPlanner().setVerbose(true)); final double[][] imputed = median.transform(d); final double[][] res = new double[][] { new double[] { 2, 1, 2 }, new double[] { 1, 2, 3 }, new double[] { 2, 2, 1 }, new double[] { 3, 5, 2 } }; assertTrue(MatUtils.equalsExactly(res, imputed)); System.out.println();/* w w w.j a v a 2 s . com*/ }
From source file:org.jfree.data.statistics.MeanAndStandardDeviation.java
/** * Returns the mean as a double primitive. If the underlying mean is * <code>null</code>, this method will return <code>Double.NaN</code>. * * @return The mean./*from ww w. ja va 2 s . c o m*/ * * @see #getMean() * * @since 1.0.7 */ public double getMeanValue() { double result = Double.NaN; if (this.mean != null) { result = this.mean.doubleValue(); } return result; }
From source file:dr.math.distributions.TruncatedDistribution.java
public double quantile(double y) { if (y == 0)/*from www . java 2 s . c o m*/ return lower; if (y == 1.0) return upper; if (Double.isInfinite(lower) && Double.isInfinite(upper)) { return source.quantile(y); } try { return super.inverseCumulativeProbability(y); } catch (MathException e) { // throw MathRuntimeException.createIllegalArgumentException( // 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; // "Couldn't calculate beta quantile for alpha = " + alpha + ", beta = " + beta + ": " +e.getMessage()); } }