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.cloudera.oryx.common.stats.IntegerWeightedMean.java
@Override public void clear() { count = 0; totalWeight = 0; mean = Double.NaN; }
From source file:MathFunc.java
/** * Returns the arc sine of an angle, in the range of <code>-Math.PI/2</code> through * <code>Math.PI/2</code>. Special cases: * <ul>/*from w w w . j a v a 2 s . co m*/ * <li>If the argument is <code>NaN</code> or its absolute value is greater than 1, * then the result is <code>NaN</code>. * <li>If the argument is zero, then the result is a zero with the same sign * as the argument. * </ul> * * @param a - the value whose arc sine is to be returned. * @return the arc sine of the argument. */ public static double asin(double a) { // Special cases. if (Double.isNaN(a) || Math.abs(a) > 1.0) { return Double.NaN; } if (a == 0.0) { return a; } // Calculate the arc sine. double aSquared = a * a; double arcSine = atan2(a, Math.sqrt(1 - aSquared)); return arcSine; }
From source file:org.talend.dataprofiler.chart.preview.DQRuleItemLabelGenerator.java
@Override protected Object[] createItemArray(CategoryDataset dataset, int row, int column) { Object[] result = new Object[4]; result[0] = dataset.getRowKey(row).toString(); result[1] = dataset.getColumnKey(column).toString(); Number value = dataset.getValue(row, column); if (value != null && !value.equals(Double.NaN)) { if (super.getNumberFormat() != null) { result[2] = super.getNumberFormat().format(value); } else if (super.getDateFormat() != null) { result[2] = super.getDateFormat().format(value); }// w w w . jav a 2s . com double total = DataUtilities.calculateColumnTotal(dataset, column); double percent = value.doubleValue() / total; // MOD qiongli bug 21589,override for just changeing this line.avoid 99.99% to show 100% // result[3] = this.percentFormat.format(percent); result[3] = stringformat(percent, 0).toString(); } else { result[2] = "-"; //$NON-NLS-1$ result[3] = "-"; //$NON-NLS-1$ } return result; }
From source file:de.qaware.chronix.solr.type.metric.functions.aggregations.Percentile.java
/** * Calculates the percentile of the first time series. * * @param timeSeries the time series//w w w . jav a2s .c o m * @return the percentile or 0 if the list is empty */ @Override public void execute(MetricTimeSeries timeSeries, FunctionValueMap functionValueMap) { //If it is empty, we return NaN if (timeSeries.size() <= 0) { functionValueMap.add(this, Double.NaN); return; } //Else calculate the analysis value functionValueMap.add(this, de.qaware.chronix.solr.type.metric.functions.math.Percentile .evaluate(timeSeries.getValues(), percentile)); }
From source file:Main.java
/** * Return the real number represented by the String s, * or return Double.NaN if s does not represent a legal * real number./* w w w . jav a2s .co m*/ */ public static double stringToReal(String s) { try { Double d = new Double(s); return d.doubleValue(); } catch (NumberFormatException e) { return Double.NaN; } }
From source file:de.qaware.chronix.solr.query.analysis.functions.aggregations.Difference.java
/** * Calculate the difference between the first and the last value of a given time series * * @param args the time series//from w w w . j a va2 s.com * @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("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 firstValue = timeSeries.getValue(0); double lastValue = timeSeries.getValue(timeSeries.size() - 1); //return the difference return Math.abs(firstValue - lastValue); }
From source file:de.qaware.chronix.solr.query.analysis.functions.aggregations.Range.java
/** * Gets difference between the maximum and the minimum value. * It is always a positive value.//w ww . j a v a 2s. c o m * * @param args the time series * @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("Range 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; } //the values to iterate double[] values = timeSeries.getValuesAsArray(); //Initialize the values with the first element double min = values[0]; double max = values[0]; for (int i = 1; i < values.length; i++) { double current = values[i]; //check for min if (current < min) { min = current; } //check of max if (current > max) { max = current; } } //return the absolute difference return Math.abs(max - min); }
From source file:ml.shifu.core.di.builtin.binning.MunroPatBinning.java
/** * set min/max, merge same bins//from w w w .j a va 2 s . c om * * @param bins * @return */ private List<Double> binMerge(List<Double> bins) { List<Double> newBins = new ArrayList<Double>(); if (bins.size() == 0) { bins.add(Double.NaN); return bins; } Double cur = bins.get(0); newBins.add(cur); int i = 1; while (i < bins.size()) { if (Math.abs(cur - bins.get(i)) > 1e-10) { newBins.add(bins.get(i)); } cur = bins.get(i); i++; } if (newBins.size() == 1) { // special case since there is only 1 candidate in the bins double val = newBins.get(0); newBins = Arrays.asList(Double.NEGATIVE_INFINITY, val); } else if (newBins.size() == 2) { newBins.set(0, Double.NEGATIVE_INFINITY); } else { newBins.set(0, Double.NEGATIVE_INFINITY); // remove the max, and became open interval newBins.remove(newBins.size() - 1); } return newBins; }
From source file:juicebox.tools.utils.juicer.arrowhead.BlockBuster.java
/** * Actual Arrowhead algorithm - should be called separately for each chromosome * * @return contact domain list and scores for given list/control *//* w w w . j av a 2 s . c o m*/ public static void run(int chrIndex, String chrName, int chrLength, int resolution, int matrixWidth, MatrixZoomData zd, NormalizationType norm, ArrowheadScoreList list, ArrowheadScoreList control, Feature2DList contactDomainsGenomeWide, Feature2DList contactDomainListScoresGenomeWide, Feature2DList contactDomainControlScoresGenomeWide) { // used for sliding window across diagonal int increment = matrixWidth / 2; int maxDataLengthAtResolution = (int) Math.ceil(((double) chrLength) / resolution); try { // get large number of blocks (lower confidence) CumulativeBlockResults results = null; for (double signThreshold = 0.4; signThreshold >= 0; signThreshold -= 0.1) { results = callSubBlockbuster(zd, maxDataLengthAtResolution, Double.NaN, signThreshold, matrixWidth, increment, list, control, norm, resolution); if (results.getCumulativeResults().size() > 0) { break; } } // high variance threshold, fewer blocks, high confidence CumulativeBlockResults highConfidenceResults = callSubBlockbuster(zd, maxDataLengthAtResolution, 0.2f, 0.5f, matrixWidth, increment, new ArrowheadScoreList(resolution), new ArrowheadScoreList(resolution), norm, resolution); List<HighScore> uniqueBlocks = orderedSetDifference(results.getCumulativeResults(), highConfidenceResults.getCumulativeResults()); // remove the blocks that are small List<HighScore> filteredUniqueBlocks = filterBlocksBySize(uniqueBlocks, 60); appendNonConflictingBlocks(highConfidenceResults.getCumulativeResults(), filteredUniqueBlocks); // merge the high/low confidence results results.setCumulativeResults(highConfidenceResults.getCumulativeResults()); results.mergeScores(); // prior to this point, everything should be in terms of i,j indices in a binned matrix results.scaleIndicesByResolution(resolution); // if any contact domains are found if (results.getCumulativeResults().size() > 0) { if (HiCGlobals.printVerboseComments) { System.out.println("Initial # of contact domains: " + results.getCumulativeResults().size()); } // merge/bin domains in very close proximity List<HighScore> binnedScores = binScoresByDistance(results.getCumulativeResults(), 5 * resolution); binnedScores = binScoresByDistance(binnedScores, 10 * resolution); Collections.sort(binnedScores, Collections.reverseOrder()); // convert to Feature2DList format Feature2DList blockResults = Feature2DParser.parseHighScoreList(chrIndex, chrName, resolution, binnedScores); Feature2DList blockResultListScores = Feature2DParser.parseArrowheadScoreList(chrIndex, chrName, results.getCumulativeInternalList()); Feature2DList blockResultControlScores = Feature2DParser.parseArrowheadScoreList(chrIndex, chrName, results.getCumulativeInternalControl()); // add results to genome-wide accumulator contactDomainsGenomeWide.add(blockResults); contactDomainListScoresGenomeWide.add(blockResultListScores); contactDomainControlScoresGenomeWide.add(blockResultControlScores); } else { if (HiCGlobals.printVerboseComments) { System.out.println("No contact domains found for chromosome " + chrName); } } } catch (IOException e) { System.err.println("Data not available for this chromosome."); } }
From source file:beast.math.distributions.NegativeBinomialDistribution.java
public double quantile(double y) { // TB - I'm having trouble implementing this return Double.NaN; }