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.cti.vpx.controls.graph.utilities.ui.graphs.waterfallGraph.ArithmeticMean.java
public void clear() { m1 = Double.NaN; n = 0; dev = Double.NaN; nDev = Double.NaN; }
From source file:com.ironiacorp.statistics.r.type.GenericAnovaResult.java
public Double getMainEffectP(String factorName) { if (mainEffects.get(factorName) == null) { return Double.NaN; }/*from ww w . j av a 2 s .co m*/ return mainEffects.get(factorName).getPValue(); }
From source file:org.jfree.data.statistics.Statistics.java
/** * Returns the mean of an array of numbers. * * @param values the values ({@code null} not permitted). * @param includeNullAndNaN a flag that controls whether or not * {@code null} and {@code Double.NaN} values are included * in the calculation (if either is present in the array, the result is * {@link Double#NaN})./*from w w w. j a va2 s. c o m*/ * * @return The mean. * * @since 1.0.3 */ public static double calculateMean(Number[] values, boolean includeNullAndNaN) { ParamChecks.nullNotPermitted(values, "values"); double sum = 0.0; double current; int counter = 0; for (int i = 0; i < values.length; i++) { // treat nulls the same as NaNs if (values[i] != null) { current = values[i].doubleValue(); } else { current = Double.NaN; } // calculate the sum and count if (includeNullAndNaN || !Double.isNaN(current)) { sum = sum + current; counter++; } } double result = (sum / counter); return result; }
From source file:br.unicamp.ic.recod.gpsi.applications.gpsiTimeSeriesCreator.java
@Override public void run() throws Exception { String datasetsPath = Paths.get(super.datasetPath).getParent().getParent().toString(); System.out.println(datasetsPath); HashMap<Byte, double[][]> indicesMap = new HashMap<>(); ArrayList<double[]> entities; double[][] series; int daysCount = 0, i, dayIndex; gpsiRawDataset rawDataset;/*from www . j a va2s . c om*/ gpsiMLDataset dataset; VectorialMean vmean; Mean mean = new Mean(); File[] days, years = new File(datasetsPath).listFiles(File::isDirectory); Arrays.sort(years); for (File year : years) daysCount += 365 + (Integer.parseInt(year.getName()) % 4 == 0 ? 1 : 0); for (Byte label : classLabels) { series = new double[daysCount][descriptors.length]; for (double[] row : series) Arrays.fill(row, Double.NaN); indicesMap.put(label, series); } daysCount = 0; for (File year : years) { days = new File(year.getAbsolutePath()).listFiles(File::isDirectory); Arrays.sort(days); for (File day : days) { dayIndex = daysCount + Integer.parseInt(day.getName()) - 1; rawDataset = datasetReader.readDataset(day.getAbsolutePath() + "/", null, 0.0); rawDataset.assignFolds(new byte[] { 0 }, null, null); for (i = 0; i < descriptors.length; i++) { dataset = new gpsiMLDataset(descriptors[i]); dataset.loadTrainingSet(rawDataset.getTrainingEntities(), true); for (Byte label : classLabels) { if (!dataset.getTrainingEntities().containsKey(label)) { indicesMap.get(label)[dayIndex][i] = Double.NaN; continue; } vmean = new VectorialMean(dataset.getDimensionality()); entities = (ArrayList<double[]>) dataset.getTrainingEntities().get(label); for (double[] v : entities) vmean.increment(v); indicesMap.get(label)[dayIndex][i] = mean.evaluate(vmean.getResult()); } } } daysCount += 365 + (Integer.parseInt(year.getName()) % 4 == 0 ? 1 : 0); } for (Byte label : classLabels) stream.register(new gpsiDoubleCsvIOElement(indicesMap.get(label), names, "series/" + label + ".csv")); }
From source file:com.whizzosoftware.hobson.rest.v1.resource.device.DeviceTelemetryResource.java
/** * @api {get} /api/v1/users/:userId/hubs/:hubId/plugins/:pluginId/devices/:deviceId/telemetry Get device variable telemetry * @apiVersion 0.1.8// w w w . ja v a 2 s .co m * @apiName GetDeviceTelemetry * @apiDescription Retrieves telemetry for a specific device variable. * @apiGroup Devices * @apiSuccessExample {json} Success Response: * { * "tempF": { * "1408390215763": 72.0 * } * }, * { * "targetTempF": { * "1408390215763": 73.0 * } * } */ @Override protected Representation get() { HobsonRestContext ctx = HobsonRestContext.createContext(this, getRequest()); String pluginId = getAttribute("pluginId"); String deviceId = getAttribute("deviceId"); long endTime = System.currentTimeMillis() / 1000; // TODO: should be pulled from request TelemetryInterval interval = TelemetryInterval.HOURS_24; // TODO: should be pulled from request Map<String, Collection<TemporalValue>> telemetry = deviceManager.getDeviceTelemetry(ctx.getUserId(), ctx.getHubId(), pluginId, deviceId, endTime, interval); JSONObject results = new JSONObject(); for (String varName : telemetry.keySet()) { Collection<TemporalValue> varTm = telemetry.get(varName); JSONObject seriesJSON = new JSONObject(); results.put(varName, seriesJSON); for (TemporalValue value : varTm) { Double d = (Double) value.getValue(); if (d != null && !d.equals(Double.NaN)) { seriesJSON.put(Long.toString(value.getTime()), d); } } } return new JsonRepresentation(results); }
From source file:edu.cudenver.bios.power.glmm.GLMMTestPillaiBartlett.java
/** * Calculate the denominator degrees of freedom for the PBT, based on * whether the null or alternative hypothesis is assumed true. * /*www. ja v a2 s . c o m*/ * @param type distribution type * @return denominator degrees of freedom * @throws IllegalArgumentException */ @Override public double getDenominatorDF(DistributionType type) { // a = #rows in between subject contrast matrix, C double a = C.getRowDimension(); // b = #columns in within subject contrast matrix double b = U.getColumnDimension(); // minimum of a and b dimensions double s = (a < b) ? a : b; double df = Double.NaN; if (fMethod == FApproximation.PILLAI_ONE_MOMENT || fMethod == FApproximation.PILLAI_ONE_MOMENT_OMEGA_MULT) { df = s * ((totalN - rank) - b + s); } else { double mu1 = a * b / (totalN - rank + a); double factor1 = (totalN - rank + a - b) / (totalN - rank + a - 1); double factor2 = (totalN - rank) / (totalN - rank + a + 2); double variance = 2 * a * b * factor1 * factor2 / ((totalN - rank + a) * (totalN - rank + a)); double mu2 = variance + mu1 * mu1; double m1 = mu1 / s; double m2 = mu2 / (s * s); double denom = m2 - m1 * m1; df = 2 * (m1 - m2) * (1 - m1) / denom; } return df; }
From source file:geogebra.common.kernel.algos.AlgoRootNewton.java
public final double calcRoot(Function fun, double start) { double root = Double.NaN; if (rootFinderBrent == null) rootFinderBrent = new BrentSolver(Kernel.STANDARD_PRECISION); // try Brent method with borders close to start value try {// w w w .j a v a 2s . com // arbitrary (used to depend on screen width) double step = 1; root = rootFinderBrent.solve(MAX_ITERATIONS, new RealRootAdapter(fun), start - step, start + step, start); if (checkRoot(fun, root)) { // System.out.println("1. Brent worked: " + root); return root; } } catch (Exception e) { root = Double.NaN; } // try Brent method on valid interval around start double[] borders = getDomain(fun, start); try { root = rootFinderBrent.solve(MAX_ITERATIONS, new RealRootAdapter(fun), borders[0], borders[1], start); if (checkRoot(fun, root)) { // System.out.println("2. Brent worked: " + root); return root; } } catch (Exception e) { root = Double.NaN; } // try Newton's method RealRootDerivFunction derivFun = fun.getRealRootDerivFunction(); if (derivFun != null) { // check if fun(start) is defined double eval = fun.evaluate(start); if (Double.isNaN(eval) || Double.isInfinite(eval)) { // shift left border slightly right borders[0] = 0.9 * borders[0] + 0.1 * borders[1]; start = (borders[0] + borders[1]) / 2; } if (rootFinderNewton == null) { rootFinderNewton = new NewtonSolver(); } try { root = rootFinderNewton.solve(MAX_ITERATIONS, new RealRootDerivAdapter(derivFun), borders[0], borders[1], start); if (checkRoot(fun, root)) { // System.out.println("Newton worked: " + root); return root; } } catch (Exception e) { root = Double.NaN; } } // neither Brent nor Newton worked return Double.NaN; }
From source file:org.jfree.data.xy.AbstractXYDataset.java
/** * Returns the y-value (as a double primitive) for an item within a series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value.//from w ww . j a v a2 s.c om */ public double getYValue(int series, int item) { double result = Double.NaN; Number y = getY(series, item); if (y != null) { result = y.doubleValue(); } return result; }
From source file:controller.ViewPackageController.java
@RequestMapping(value = "/pickPackage/{id}", method = RequestMethod.GET) public String pickPackage(ModelMap mm, Authentication authen, @PathVariable(value = "id") int id) { try {//w ww.j a va2 s. c o m List<Distributor> listDis = disModel.getAll(); Packages pack = packModel.getByID(id); mm.put("listDistributor", listDis); Customer cus = cusModel.find(authen.getName(), "username", false).get(0); mm.addAttribute("requirement", new Requirement(null, cus, null, Double.NaN)); mm.put("type", pack.getType()); mm.put("packid", pack.getPackageId()); } catch (Exception ex) { ex.printStackTrace(); } return "pickPackage"; }
From source file:com.itemanalysis.psychometrics.polycor.Covariance.java
public Double value(boolean unbiased) { if (fixedValue) return covariance; if (N < 1) return Double.NaN; if (unbiased) { return covarianceNumerator / (N - 1.0); } else {/*from ww w. j av a2 s .c o m*/ return covarianceNumerator / N; } }