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:sim.portrayal.inspector.TimeSeriesChartingPropertyInspector.java
protected double valueFor(Object o) { if (o instanceof java.lang.Number) // compiler complains unless I include the full classname!!! Huh? return ((Number) o).doubleValue(); else if (o instanceof Valuable) return ((Valuable) o).doubleValue(); else if (o instanceof Boolean) return ((Boolean) o).booleanValue() ? 1 : 0; else// w ww .j a v a 2 s . c om return Double.NaN; // unknown }
From source file:net.myrrix.online.som.SelfOrganizingMaps.java
public Node[][] buildSelfOrganizedMap(FastByIDMap<float[]> vectors, int maxMapSize) { return buildSelfOrganizedMap(vectors, maxMapSize, Double.NaN); }
From source file:edu.harvard.med.screensaver.analysis.heatmaps.HeatMap.java
public double getScoredValue(int row, int column) { ResultValue rv = getResultValue(row, column); if (rv == null || rv.getNumericValue() == null) { return Double.NaN; }/*from ww w .ja va2 s . c om*/ return _scoringFunc.compute(rv.getNumericValue()); }
From source file:jsat.distributions.SingleValueDistribution.java
@Override public double skewness() { return Double.NaN; }
From source file:com.itemanalysis.psychometrics.polycor.PolyserialPlugin.java
/** * Correct polyserial correlation for spuriousness due to including the studied * item score Y in the computation of X values. This method is used for the * polyserial correlation in an item analysis. * * @return correlation corrected for spuriousness *//* w ww. j a va 2s.c om*/ public double spuriousCorrectedValue() { double[] thresholds = null; double correctedR = spuriousCorrectedPearsonCorrelation(); thresholds = getThresholds(); double thresholdProbSum = 0.0; for (int i = 0; i < thresholds.length; i++) { thresholdProbSum += norm.density(thresholds[i]); } if (thresholdProbSum == 0.0) return Double.NaN; double n = (double) freqY.getSumFreq(); double psr = Math.sqrt((n - 1.0) / n) * sdY.getResult() * correctedR / thresholdProbSum; return psr; }
From source file:fiji.plugin.trackmate.action.brownianmotion.WalkerMethodEstimator.java
/** * //ww w .ja v a2 s . c o m * @param data Containes the mean squared displacement and the Tracklength for each track. data[i][0] = MSD data[i][1] = Tracklength * @param temp Temperature of the suspension in kelvin * @param visk Viscosity of the suspension * @param framerate Framerate in hertz * @param maxdiameter The maximum diameter for the estimation */ public WalkerMethodEstimator(double[][] data, double temp, double visk, double framerate, int maxdiameter) { this.data = data; this.temp = temp; this.visk = visk; this.frameduration = 1 / framerate; minTrackLength = Integer.MAX_VALUE; maxTrackLength = Integer.MIN_VALUE; //msdMin = Double.MAX_VALUE; msdMax = Double.MIN_VALUE; //double convFact = Math.pow(10, -10); for (int i = 0; i < data.length; i++) { //10^-10 cm^2 -> cm^2 //this.data[i][0] = this.data[i][0]*convFact; //- 4*17.562862475*17.562862475*Math.pow(10, -7)*Math.pow(10, -7); if (data[i][0] > msdMax) { msdMax = data[i][0]; } if (this.data[i][1] > maxTrackLength) { maxTrackLength = (int) this.data[i][1]; } if (this.data[i][1] < minTrackLength) { minTrackLength = (int) this.data[i][1]; } //IJ.log("MSD " + this.data[i][0]); } logMapK = new double[maxTrackLength + 1]; logMapGammaK = new double[maxTrackLength + 1]; java.util.Arrays.fill(logMapK, Double.NaN); java.util.Arrays.fill(logMapGammaK, Double.NaN); maxRadiusInNm = maxdiameter / 2.0; binNumber = (int) (maxRadiusInNm / binSizeInnm); histBinNumber = (int) Math.ceil(Math.sqrt(data.length)); deltaB = msdMax / histBinNumber; histogramMSD = new double[histBinNumber]; java.util.Arrays.fill(histogramMSD, 0); Nk = new int[maxTrackLength + 1]; java.util.Arrays.fill(Nk, 0); for (int i = 0; i < data.length; i++) { int index = (int) this.data[i][1]; Nk[index]++; int index2 = (int) Math.floor(data[i][0] / deltaB - 0.001); histogramMSD[index2]++; } }
From source file:it.unibas.spicybenchmark.operators.generators.ext.simpack.tree.TreeEditDistanceGeneratorSimPack.java
public double compute(Configuration configuration) { ITreeNode tree1 = CommonSimPack.generateSample(configuration.getExpectedInstanceAbsolutePath()); ITreeNode tree2 = CommonSimPack.generateSample(configuration.getTranslatedInstanceAbsolutePath()); try {/*from ww w . java2 s. com*/ ITreeNodeComparator comparator = loadTreeNodeComparator(configuration); AbstractDistanceConversion conversion = loadDistanceConversion(configuration); double weightInsert = configuration.getTreeEditDistanceValienteWeightInsert(); double weightDelete = configuration.getTreeEditDistanceValienteWeightDelete(); double weightSubstitute = configuration.getTreeEditDistanceValienteWeightSubstitute(); TreeEditDistance calc = new TreeEditDistance(new SimpleTreeAccessor(tree1), new SimpleTreeAccessor(tree2), comparator, conversion); calc.setWeightInsert(weightInsert); calc.setWeightDelete(weightDelete); calc.setWeightSubstitute(weightSubstitute); calc.calculate(); double treeEditDistance = calc.getTreeEditDistance(); logger.debug("TED " + treeEditDistance); logger.debug("TreeNodeComparator " + calc.getComparator()); logger.debug("Similarity " + calc.getSimilarity()); logger.debug("ShortestPath " + calc.getShortestPath()); logger.debug("Weight Delete " + calc.getWeightDelete()); logger.debug("Weight Insert " + calc.getWeightInsert()); logger.debug("Weight Substitute " + calc.getWeightSubstitute()); logger.debug("getWorstCaseRetainStructure " + calc.getWorstCaseRetainStructure()); logger.debug("getWorstCaseSubstituteAll " + calc.getWorstCaseSubstituteAll()); logger.debug("getWorstCaseSumOfNodes " + calc.getWorstCaseSumOfNodes()); logger.debug("----------------------"); return treeEditDistance; } catch (NullPointerException e) { e.printStackTrace(); } catch (InvalidElementException e) { e.printStackTrace(); } return Double.NaN; }
From source file:com.joptimizer.optimizers.NewtonLEConstrainedISP.java
@Override public int optimize() throws Exception { Log.d(MainActivity.JOPTIMIZER_LOGTAG, "optimize"); OptimizationResponse response = new OptimizationResponse(); //checking responsibility if (getFi() != null) { // forward to the chain return forwardOptimizationRequest(); }// w ww . j a va2 s . c om long tStart = System.currentTimeMillis(); DoubleMatrix1D X0 = getInitialPoint(); if (X0 == null) { if (getA() != null) { X0 = F1.make(findEqFeasiblePoint(getA().toArray(), getB().toArray())); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "Switch to the linear equality feasible starting point Newton algorithm "); NewtonLEConstrainedFSP opt = new NewtonLEConstrainedFSP(); OptimizationRequest req = getOptimizationRequest(); req.setInitialPoint(X0.toArray()); opt.setOptimizationRequest(req); int retcode = opt.optimize(); OptimizationResponse resp = opt.getOptimizationResponse(); setOptimizationResponse(resp); return retcode; } else { X0 = F1.make(getDim()); } } DoubleMatrix1D V0 = (getA() != null) ? F1.make(getA().rows()) : F1.make(0); if (Log.isLoggable(MainActivity.JOPTIMIZER_LOGTAG, Log.DEBUG)) { Log.d(MainActivity.JOPTIMIZER_LOGTAG, "X0: " + ArrayUtils.toString(X0.toArray())); } DoubleMatrix1D X = X0; DoubleMatrix1D V = V0; double F0X; DoubleMatrix1D gradX = null; DoubleMatrix2D hessX = null; DoubleMatrix1D rDualXV = null; DoubleMatrix1D rPriX = null; double previousF0X = Double.NaN; double previousRPriXNorm = Double.NaN; double previousRXVNorm = Double.NaN; int iteration = 0; while (true) { iteration++; F0X = getF0(X); if (Log.isLoggable(MainActivity.JOPTIMIZER_LOGTAG, Log.DEBUG)) { Log.d(MainActivity.JOPTIMIZER_LOGTAG, "iteration " + iteration); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "X=" + ArrayUtils.toString(X.toArray())); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "V=" + ArrayUtils.toString(V.toArray())); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "f(X)=" + F0X); } // if(!Double.isNaN(previousF0X)){ // if (previousF0X < F0X) { // throw new Exception("critical minimization problem"); // } // } // previousF0X = F0X; // custom exit condition if (checkCustomExitConditions(X)) { response.setReturnCode(OptimizationResponse.SUCCESS); break; } gradX = getGradF0(X); hessX = getHessF0(X); rDualXV = rDual(X, V, gradX); rPriX = rPri(X); // exit condition double rPriXNorm = Math.sqrt(ALG.norm2(rPriX)); double rDualXVNorm = Math.sqrt(ALG.norm2(rDualXV)); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "rPriXNorm : " + rPriXNorm); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "rDualXVNorm: " + rDualXVNorm); double rXVNorm = Math.sqrt(Math.pow(rPriXNorm, 2) + Math.pow(rDualXVNorm, 2)); if (rPriXNorm <= getTolerance() && rXVNorm <= getTolerance()) { response.setReturnCode(OptimizationResponse.SUCCESS); break; } // Newton step and decrement if (this.kktSolver == null) { this.kktSolver = new BasicKKTSolver(); } if (isCheckKKTSolutionAccuracy()) { kktSolver.setCheckKKTSolutionAccuracy(isCheckKKTSolutionAccuracy()); kktSolver.setToleranceKKT(getToleranceKKT()); } kktSolver.setHMatrix(hessX.toArray()); kktSolver.setGVector(rDualXV.toArray()); if (getA() != null) { kktSolver.setAMatrix(getA().toArray()); kktSolver.setATMatrix(getAT().toArray()); kktSolver.setHVector(rPriX.toArray()); } double[][] sol = kktSolver.solve(); DoubleMatrix1D stepX = F1.make(sol[0]); DoubleMatrix1D stepV = (sol[1] != null) ? F1.make(sol[1]) : F1.make(0); if (Log.isLoggable(MainActivity.JOPTIMIZER_LOGTAG, Log.DEBUG)) { Log.d(MainActivity.JOPTIMIZER_LOGTAG, "stepX: " + ArrayUtils.toString(stepX.toArray())); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "stepV: " + ArrayUtils.toString(stepV.toArray())); } // // exit condition // double rPriXNorm = Math.sqrt(ALG.norm2(rPriX)); // double rDualXVNorm = Math.sqrt(ALG.norm2(rDualXV)); // Log.d(MainActivity.JOPTIMIZER_LOGTAG,"rPriXNorm : "+rPriXNorm); // Log.d(MainActivity.JOPTIMIZER_LOGTAG,"rDualXVNorm: "+rDualXVNorm); // double rXVNorm = Math.sqrt(Math.pow(rPriXNorm, 2)+ Math.pow(rDualXVNorm, 2)); // if (rPriXNorm <= getTolerance() && rXVNorm <= getTolerance()) { // response.setReturnCode(OptimizationResponse.SUCCESS); // break; // } // iteration limit condition if (iteration == getMaxIteration()) { response.setReturnCode(OptimizationResponse.WARN); Log.w(MainActivity.JOPTIMIZER_LOGTAG, "Max iterations limit reached"); break; } // progress conditions if (isCheckProgressConditions()) { if (!Double.isNaN(previousRPriXNorm) && !Double.isNaN(previousRXVNorm)) { if ((previousRPriXNorm <= rPriXNorm && rPriXNorm >= getTolerance()) || (previousRXVNorm <= rXVNorm && rXVNorm >= getTolerance())) { Log.w(MainActivity.JOPTIMIZER_LOGTAG, "No progress achieved, exit iterations loop without desired accuracy"); response.setReturnCode(OptimizationResponse.WARN); break; } } } previousRPriXNorm = rPriXNorm; previousRXVNorm = rXVNorm; // backtracking line search double s = 1d; DoubleMatrix1D X1 = null; DoubleMatrix1D V1 = null; DoubleMatrix1D gradX1 = null; DoubleMatrix1D rDualX1V1 = null; DoubleMatrix1D rPriX1V1 = null; double previousNormRX1V1 = Double.NaN; while (true) { // @TODO: can we use 9.7.1? X1 = X.copy().assign(stepX.copy().assign(Mult.mult(s)), Functions.plus);// X + s*stepX V1 = V.copy().assign(stepV.copy().assign(Mult.mult(s)), Functions.plus);// V + s*stepV if (isInDomainF0(X1)) { gradX1 = getGradF0(X1); rDualX1V1 = rDual(X1, V1, gradX1); rPriX1V1 = rPri(X1); double normRX1V1 = Math.sqrt(ALG.norm2(rDualX1V1) + ALG.norm2(rPriX1V1)); if (normRX1V1 <= (1 - getAlpha() * s) * rXVNorm) { break; } Log.d(MainActivity.JOPTIMIZER_LOGTAG, "normRX1V1: " + normRX1V1); if (!Double.isNaN(previousNormRX1V1)) { if (previousNormRX1V1 <= normRX1V1) { Log.w(MainActivity.JOPTIMIZER_LOGTAG, "No progress achieved in backtracking with norm"); break; } } previousNormRX1V1 = normRX1V1; } s = getBeta() * s; } Log.d(MainActivity.JOPTIMIZER_LOGTAG, "s: " + s); // update X = X1; V = V1; } long tStop = System.currentTimeMillis(); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "time: " + (tStop - tStart)); response.setSolution(X.toArray()); setOptimizationResponse(response); return response.getReturnCode(); }
From source file:de.thkwalter.et.ortskurve.Startpunktbestimmung.java
/** * Diese Methode berechnet den Startpunkt aus den ersten drei Messpunkten. * /*from ww w . ja va2 s . com*/ * @return Der Startpunkt. Die erste Komponente des Feldes reprsentiert die x-Komponente des Mittelpunktes, die zweite * Komponente die y-Komponente, die dritte Komponente den Radius. */ private static double[] startpunktBestimmen(Vector2D[] messpunkteZurStartpunktbestimmung) { // Die Felder fr die Koeffizientenmatrix und die Inhomogenitt werden definiert. double[][] koeffizienten = new double[3][]; double[] inhomogenitaet = new double[3]; // Einige Hilfsgren werden deklariert. double[] zeile = null; double x = Double.NaN; double y = Double.NaN; // In der folgenden Schleife werden die Koeffizientenmatrix und die Inhomogenitt initialisiert. for (int i = 0; i < 3; i++) { // Die x- und y-Komponente eines Punktes werden gelesen. x = messpunkteZurStartpunktbestimmung[i].getX(); y = messpunkteZurStartpunktbestimmung[i].getY(); // Eine Zeile der Koeffizientenmatrix wird initialisiert zeile = new double[3]; zeile[0] = 1; zeile[1] = -x; zeile[2] = -y; koeffizienten[i] = zeile; // Eine Komponente des Inhomogenittsvektors wird initialisiert. inhomogenitaet[i] = -(x * x + y * y); } // Die Koeffizientenmatrix wird erzeugt. RealMatrix koeffizientenmatrix = new Array2DRowRealMatrix(koeffizienten); // Der Inhomogenittsvektor wird erzeugt. RealVector inhomogenitaetsvektor = new ArrayRealVector(inhomogenitaet, false); // Der Lsungsalgorithmus fr das lineare Gleichungssystem wird erzeugt. DecompositionSolver alorithmus = new LUDecomposition(koeffizientenmatrix).getSolver(); // Das inhomogene Gleichungssystem wird gelst. RealVector loesung = null; try { loesung = alorithmus.solve(inhomogenitaetsvektor); } catch (SingularMatrixException singularMatrixException) { // Die Fehlermeldung fr den Entwickler wird erzeugt und protokolliert. String fehlermeldung = "Die Matrix aus den Punkten " + messpunkteZurStartpunktbestimmung[0] + ", " + messpunkteZurStartpunktbestimmung[1] + " und " + messpunkteZurStartpunktbestimmung[2] + " ist singulr."; Startpunktbestimmung.logger.severe(fehlermeldung); // Die Ausnahme wird erzeugt und mit der Fehlermeldung fr den Benutzer initialisiert. String jsfMeldung = "Eine von den Messpunkten (" + messpunkteZurStartpunktbestimmung[0].getX() + ", " + messpunkteZurStartpunktbestimmung[0].getY() + "), (" + messpunkteZurStartpunktbestimmung[1].getX() + ", " + messpunkteZurStartpunktbestimmung[1].getY() + ") und (" + messpunkteZurStartpunktbestimmung[2].getX() + ", " + messpunkteZurStartpunktbestimmung[2].getY() + ")" + " abhngige Matrix ist singur. Der " + "Berechnungsalgorithmus bentigt jedoch eine regulre Matrix! Entfernen Sie bitte einen der oben " + "angegebenen Messpunkte."; ApplicationRuntimeException applicationRuntimeException = new ApplicationRuntimeException(jsfMeldung); throw applicationRuntimeException; } // Der Startpunkt wird aus der Lsung des linearen Gleichungssystems bestimmt. double xMittelpunkt = 0.5 * loesung.getEntry(1); double yMittelpunkt = 0.5 * loesung.getEntry(2); double radius = Math.sqrt(xMittelpunkt * xMittelpunkt + yMittelpunkt * yMittelpunkt - loesung.getEntry(0)); // Der Startpunkt wird zurckgegeben. return new double[] { xMittelpunkt, yMittelpunkt, radius }; }
From source file:de.biomedical_imaging.ij.nanotrackj.WalkerMethodEstimator.java
/** * //from w w w. ja v a 2s . c om * @param data Containes the mean squared displacement and the Tracklength for each track. data[i][0] = MSD data[i][1] = Tracklength * @param temp Temperature of the suspension in kelvin * @param visk Viscosity of the suspension * @param framerate * @param maxdiameter The maximum diameter for the estimation. 0 = Maximum Diameter is estimated automatically */ public WalkerMethodEstimator(double[][] data, double temp, double visk, double framerate, int maxdiameter) { this.temp = temp; this.visk = visk; this.framerate = 1.0 / framerate; this.data = data; kMin = Integer.MAX_VALUE; kMax = Integer.MIN_VALUE; msdMin = Double.MAX_VALUE; msdMax = Double.MIN_VALUE; double convFact = Math.pow(10, -10); for (int i = 0; i < data.length; i++) { //10^-10 cm^2 -> cm^2 this.data[i][0] = this.data[i][0] * convFact; //- 4*17.562862475*17.562862475*Math.pow(10, -7)*Math.pow(10, -7); if (this.data[i][0] > msdMax) { msdMax = this.data[i][0]; } if (this.data[i][0] < msdMin) { msdMin = this.data[i][0]; } if (this.data[i][1] > kMax) { kMax = (int) this.data[i][1]; } if (this.data[i][1] < kMin) { kMin = (int) this.data[i][1]; } //IJ.log("MSD " + this.data[i][0]); } logMapK = new double[kMax + 1]; logMapGammaK = new double[kMax + 1]; java.util.Arrays.fill(logMapK, Double.NaN); java.util.Arrays.fill(logMapGammaK, Double.NaN); maxRadiusInNm = maxdiameter / 2.0; if (maxdiameter == 0) { maxRadiusInNm = NanoTrackJ_.getInstance() .diffCoeffToDiameter((msdMin * Math.pow(10, 10)) / 4 * (framerate)); maxRadiusInNm = (maxRadiusInNm + 1) / 2; } binNumber = (int) (maxRadiusInNm / binSizeInnm); histBinNumber = (int) Math.ceil(Math.sqrt(data.length)); deltaB = msdMax / histBinNumber; histogramMSD = new double[histBinNumber]; java.util.Arrays.fill(histogramMSD, 0); Nk = new int[kMax + 1]; java.util.Arrays.fill(Nk, 0); for (int i = 0; i < data.length; i++) { int index = (int) this.data[i][1]; Nk[index]++; int index2 = (int) Math.floor(data[i][0] / deltaB - 0.001); histogramMSD[index2]++; } }