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.itemanalysis.psychometrics.irt.model.Irm4PL.java
public double derivTheta(double theta) { return Double.NaN; }
From source file:com.caseystella.analytics.outlier.batch.rpca.RPCAOutlierAlgorithm.java
public double outlierScore(List<DataPoint> dataPoints, DataPoint value) { double[] inputData = new double[dataPoints.size() + 1]; int numNonZero = 0; if (scaling != ScalingFunctions.NONE) { int i = 0; final DescriptiveStatistics stats = new DescriptiveStatistics(); for (DataPoint dp : dataPoints) { inputData[i++] = dp.getValue(); stats.addValue(dp.getValue()); numNonZero += dp.getValue() > EPSILON ? 1 : 0; }/* w ww.j a v a2s .co m*/ inputData[i] = value.getValue(); GlobalStatistics globalStats = new GlobalStatistics() { { setMax(stats.getMax()); setMin(stats.getMin()); setMax(stats.getMean()); setStddev(stats.getStandardDeviation()); } }; for (i = 0; i < inputData.length; ++i) { inputData[i] = scaling.scale(inputData[i], globalStats); } } else { int i = 0; for (DataPoint dp : dataPoints) { inputData[i++] = dp.getValue(); numNonZero += dp.getValue() > EPSILON ? 1 : 0; } inputData[i] = value.getValue(); } int nCols = 1; int nRows = inputData.length; if (numNonZero > minRecords) { AugmentedDickeyFuller dickeyFullerTest = new AugmentedDickeyFuller(inputData); double[] inputArrayTransformed = inputData; if (!this.isForceDiff && dickeyFullerTest.isNeedsDiff()) { // Auto Diff inputArrayTransformed = dickeyFullerTest.getZeroPaddedDiff(); } else if (this.isForceDiff) { // Force Diff inputArrayTransformed = dickeyFullerTest.getZeroPaddedDiff(); } if (this.spenalty == null) { this.lpenalty = this.LPENALTY_DEFAULT; this.spenalty = this.SPENALTY_DEFAULT / Math.sqrt(Math.max(nCols, nRows)); } // Calc Mean double mean = 0; for (int n = 0; n < inputArrayTransformed.length; n++) { mean += inputArrayTransformed[n]; } mean /= inputArrayTransformed.length; // Calc STDEV double stdev = 0; for (int n = 0; n < inputArrayTransformed.length; n++) { stdev += Math.pow(inputArrayTransformed[n] - mean, 2); } stdev = Math.sqrt(stdev / (inputArrayTransformed.length - 1)); // Transformation: Zero Mean, Unit Variance for (int n = 0; n < inputArrayTransformed.length; n++) { inputArrayTransformed[n] = (inputArrayTransformed[n] - mean) / stdev; } // Read Input Data into Array // Read Input Data into Array double[][] input2DArray = new double[nRows][nCols]; input2DArray = VectorToMatrix(inputArrayTransformed, nRows, nCols); RPCA rSVD = new RPCA(input2DArray, this.lpenalty, this.spenalty); double[][] outputE = rSVD.getE().getData(); double[][] outputS = rSVD.getS().getData(); double[][] outputL = rSVD.getL().getData(); return outputS[nRows - 1][0]; } else { return Double.NaN; } }
From source file:dr.math.distributions.BetaDistribution.java
/** * quantile (inverse cumulative density function) of the distribution * * @param y argument//from w w w . j a v a2 s .c o m * @return icdf value */ public double quantile(double y) { if (y == 0) { return 0; } else if (y == 1) { return 1; } else { 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()); } } }
From source file:guineu.modules.dataanalysis.correlations.CorrelationTask.java
private RealMatrix getCorrelation(PeakListRow row, PeakListRow row2, List<String> sampleNames) { List<Double[]> data = new ArrayList<Double[]>(); for (int i = 0; i < sampleNames.size(); i++) { try {// w w w.j av a 2s .c om if ((Double) row.getPeak(sampleNames.get(i)) != Double.NaN && (Double) row2.getPeak(sampleNames.get(i)) != Double.NaN && (Double) row.getPeak(sampleNames.get(i)) != 0.0 && (Double) row2.getPeak(sampleNames.get(i)) != 0.0) { Double[] dat = new Double[2]; dat[0] = (Double) row.getPeak(sampleNames.get(i)); dat[1] = (Double) row2.getPeak(sampleNames.get(i)); data.add(dat); // System.out.println(sampleNames.elementAt(i) + " - " + row.getPeak(sampleNames.elementAt(i)) + " - " + row2.getPeak(sampleNames.elementAt(i))); } } catch (Exception e) { //System.out.println(row.getPeak(sampleNames.elementAt(i)) + " - " + row2.getPeak(sampleNames.elementAt(i))); //e.printStackTrace(); } } double[][] dataMatrix = new double[data.size()][2]; int count = 0; for (Double[] dat : data) { dataMatrix[count][0] = dat[0]; dataMatrix[count++][1] = dat[1]; } RealMatrix matrix = new BlockRealMatrix(dataMatrix); return matrix; }
From source file:com.rapidminer.gui.plotter.charts.BubbleChartPlotter.java
private void prepareNumericalData() { DataTable dataTable = getDataTable(); this.nominal = false; xyzDataSet = new DefaultXYZDataset(); if (axis[X_AXIS] >= 0 && axis[Y_AXIS] >= 0 && axis[BUBBLE_SIZE_AXIS] >= 0) { this.bubbleSizeMin = Double.POSITIVE_INFINITY; this.bubbleSizeMax = Double.NEGATIVE_INFINITY; this.xAxisMin = Double.POSITIVE_INFINITY; this.xAxisMax = Double.NEGATIVE_INFINITY; this.yAxisMin = Double.POSITIVE_INFINITY; this.yAxisMax = Double.NEGATIVE_INFINITY; this.minColor = Double.POSITIVE_INFINITY; this.maxColor = Double.NEGATIVE_INFINITY; List<double[]> dataList = new LinkedList<>(); synchronized (dataTable) { Iterator<DataTableRow> i = dataTable.iterator(); while (i.hasNext()) { DataTableRow row = i.next(); double xValue = row.getValue(axis[X_AXIS]); double yValue = row.getValue(axis[Y_AXIS]); double bubbleSizeValue = row.getValue(axis[BUBBLE_SIZE_AXIS]); double colorValue = Double.NaN; if (colorColumn >= 0) { colorValue = row.getValue(colorColumn); }//from w ww.ja v a 2s. com if (!Double.isNaN(xValue) && !Double.isNaN(yValue) && !Double.isNaN(bubbleSizeValue)) { double[] data = new double[4]; data[X_AXIS] = xValue; data[Y_AXIS] = yValue; data[BUBBLE_SIZE_AXIS] = bubbleSizeValue; data[3] = colorValue; this.bubbleSizeMin = MathFunctions.robustMin(this.bubbleSizeMin, bubbleSizeValue); this.bubbleSizeMax = MathFunctions.robustMax(this.bubbleSizeMax, bubbleSizeValue); this.xAxisMin = MathFunctions.robustMin(this.xAxisMin, xValue); this.yAxisMin = MathFunctions.robustMin(this.yAxisMin, yValue); this.xAxisMax = MathFunctions.robustMax(this.xAxisMax, xValue); this.yAxisMax = MathFunctions.robustMax(this.yAxisMax, yValue); this.minColor = MathFunctions.robustMin(this.minColor, colorValue); this.maxColor = MathFunctions.robustMax(this.maxColor, colorValue); dataList.add(data); } } } double[][] data = new double[3][dataList.size()]; this.colors = new double[dataList.size()]; int index = 0; double scaleFactor = Math.min(this.xAxisMax - this.xAxisMin, this.yAxisMax - this.yAxisMin) / 4.0d; for (double[] d : dataList) { data[X_AXIS][index] = d[X_AXIS]; data[Y_AXIS][index] = d[Y_AXIS]; data[BUBBLE_SIZE_AXIS][index] = ((d[BUBBLE_SIZE_AXIS] - bubbleSizeMin) / (bubbleSizeMax - bubbleSizeMin) + 0.1) * scaleFactor; this.colors[index] = d[3]; index++; } xyzDataSet.addSeries("All", data); } }
From source file:net.femtoparsec.jnlmin.AbstractTokenTask.java
private void dispatchError() { if (this.listeners.isEmpty()) { return;// w w w .j ava2s .c o m } MinimizerEventImpl event = new MinimizerEventImpl(); event.setMinimizerStatus(MinimizerStatus.ERROR); event.setNbEvaluations(0); event.setNbIterations(0); event.setParameters(null); event.setPenalty(Double.NaN); this.dispatchEvent(event); }
From source file:com.facebook.presto.AbstractTestQueries.java
@Test void testSpecialFloatingPointValues() throws Exception { MaterializedResult actual = computeActual("SELECT nan(), infinity(), -infinity()"); MaterializedTuple tuple = Iterables.getOnlyElement(actual.getMaterializedTuples()); assertEquals(tuple.getField(0), Double.NaN); assertEquals(tuple.getField(1), Double.POSITIVE_INFINITY); assertEquals(tuple.getField(2), Double.NEGATIVE_INFINITY); }
From source file:com.clust4j.algo.preprocess.ImputationTests.java
@Test public void testDefConst() { final double[][] d = new double[][] { new double[] { 1, 1, 2 }, new double[] { 1, Double.NaN, 3 }, new double[] { 8.5, 7.9, 6 }, new double[] { 9, 8, Double.NaN }, new double[] { 3.5, 2.9, 6.1 }, new double[] { 3, Double.NaN, 1 }, new double[] { 0, 0, 0 }, new double[] { 2, 4, 9 }, new double[] { 1.4, 5, 6 }, }; new BootstrapImputation().transform(d); new MeanImputation().transform(d); new MedianImputation().transform(d); new NearestNeighborImputation().transform(d); }
From source file:geogebra.common.geogebra3D.kernel3D.geos.Geo3DVec.java
final public static void complexMultiply(GeoVecInterface a, GeoVecInterface b, GeoVec2D c) { if (!Kernel.isZero(a.getZ()) || !Kernel.isZero(b.getZ())) { c.setX(Double.NaN); c.setY(Double.NaN);/* ww w. j ava2s .c o m*/ c.setMode(Kernel.COORD_COMPLEX); return; } Complex out = new Complex(a.getX(), a.getY()); out = out.multiply(new Complex(b.getX(), b.getY())); c.setX(out.getReal()); c.setY(out.getImaginary()); c.setMode(Kernel.COORD_COMPLEX); }
From source file:fr.ens.transcriptome.aozan.util.StatisticsUtils.java
/** * Compute the standard deviation for values. * @param isBiasCorrected false per default * @return standard deviation NaN if no values have been added, or 0.0 for a * single value set./* w ww .j a v a 2s . c o m*/ */ public Double getStandardDeviation(final boolean isBiasCorrected) { final double average = getMean(); double result = Double.NaN; double sum = 0.0; Double val = 0.0; double count = 0.0; if (this.ds.getN() > 0) { if (this.ds.getN() > 1) { for (int i = 0; i < this.ds.getN(); i++) { val = this.ds.getElement(i); val -= average; sum += val * val; count++; } // With bias corrected, division by count values - 1 count -= isBiasCorrected ? 1 : 0; result = Math.sqrt(sum / count); } else { result = 0.0; } } return result; }