List of usage examples for java.lang Double NEGATIVE_INFINITY
double NEGATIVE_INFINITY
To view the source code for java.lang Double NEGATIVE_INFINITY.
Click Source Link
From source file:de.cebitec.readXplorer.plotting.CreatePlots.java
public synchronized static ChartPanel createInfPlot(Map<PersistentFeature, Pair<Double, Double>> data, String xName, String yName, XYToolTipGenerator toolTip) { XYSeriesCollection normal = new XYSeriesCollection(); XYSeriesCollection posInf = new XYSeriesCollection(); XYSeriesCollection negInf = new XYSeriesCollection(); XYSeries nor = new XYSeries("Normal"); XYSeries pos = new XYSeries("Positive Infinite"); XYSeries neg = new XYSeries("Negative Infinite"); for (Iterator<PersistentFeature> it = data.keySet().iterator(); it.hasNext();) { PersistentFeature key = it.next(); Pair<Double, Double> pair = data.get(key); Double X = pair.getFirst(); Double Y = pair.getSecond(); if (Y == Double.POSITIVE_INFINITY) { Y = 0d;// w w w .ja v a2 s . com pos.add(new PlotDataItem(key, X, Y)); } if (Y == Double.NEGATIVE_INFINITY) { Y = 0d; neg.add(new PlotDataItem(key, X, Y)); } if (!Y.isInfinite() && !X.isInfinite()) { nor.add(new PlotDataItem(key, X, Y)); } } normal.addSeries(nor); posInf.addSeries(pos); negInf.addSeries(neg); JFreeChart chart = createCombinedChart(normal, posInf, negInf, xName, yName, toolTip); chart.removeLegend(); ChartPanel panel = new ChartPanel(chart, true, false, true, true, true); panel.setInitialDelay(0); panel.setMaximumDrawHeight(1080); panel.setMaximumDrawWidth(1920); panel.setMouseWheelEnabled(true); panel.setMouseZoomable(true); MouseActions mouseAction = new MouseActions(); panel.addChartMouseListener(mouseAction); ChartPanelOverlay overlay = new ChartPanelOverlay(mouseAction); panel.addOverlay(overlay); return panel; }
From source file:nl.gridline.zieook.inx.movielens.hbase.RecommendationsImportMap.java
@Override public void map(IntWritable key, VectorWritable value, Context context) throws IOException, InterruptedException { Vector similarityMatrixRow = value.get(); // Remove self similarity similarityMatrixRow.set(key.get(), Double.NEGATIVE_INFINITY); // from the equation // determine max non-zero element: (==item index) List<RecommendationElement> recommendations = new ArrayList<RecommendationElement>(); // collect non-zero items: Iterator<Element> it = similarityMatrixRow.iterateNonZero(); while (it.hasNext()) { Element e = it.next();//from w ww. j a v a 2s . c o m recommendations.add(new RecommendationElement(e.index(), e.get())); // LOG.info("created new recommendation for " + e.index()); } // sorted list of recommendations: now we have an item id, and similarity value: Collections.sort(recommendations, new SimilarityComparator()); LOG.info("sorted: " + recommendations.size()); int rank = 1; Put put = new Put(RowKeys.getRecommendationKey(collection, recommender, key.get())); for (RecommendationElement el : recommendations) { // if (el.getSimilarityValue() > 0) // { byte[] data = Recommend.getRecommendation(el.getItemIndex(), rank, el.getSimilarityValue()); put.add(RECOMMENDATION_COLUMN, Bytes.toBytes(rank), data); rank++; // } } context.write(new LongWritable(key.get()), put); }
From source file:com.opengamma.strata.math.impl.statistics.distribution.NonCentralChiSquaredDistribution.java
/** * {@inheritDoc}/* ww w .ja v a 2s. c om*/ */ @Override public double getCDF(Double x) { ArgChecker.notNull(x, "x"); if (x < 0) { return 0.0; } if ((_dofOverTwo + _lambdaOverTwo) > 1000) { return getFraserApproxCDF(x); } double regGammaStart = 0; double halfX = x / 2.0; double logX = Math.log(halfX); try { regGammaStart = Gamma.regularizedGammaP(_dofOverTwo + _k, halfX); } catch (MaxCountExceededException ex) { throw new MathException(ex); } double sum = _pStart * regGammaStart; double oldSum = Double.NEGATIVE_INFINITY; double p = _pStart; double regGamma = regGammaStart; double temp; int i = _k; // first add terms below _k while (i > 0 && Math.abs(sum - oldSum) / sum > _eps) { i--; p *= (i + 1) / _lambdaOverTwo; temp = (_dofOverTwo + i) * logX - halfX - Gamma.logGamma(_dofOverTwo + i + 1); regGamma += Math.exp(temp); oldSum = sum; sum += p * regGamma; } p = _pStart; regGamma = regGammaStart; oldSum = Double.NEGATIVE_INFINITY; i = _k; while (Math.abs(sum - oldSum) / sum > _eps) { i++; p *= _lambdaOverTwo / i; temp = (_dofOverTwo + i - 1) * logX - halfX - Gamma.logGamma(_dofOverTwo + i); regGamma -= Math.exp(temp); oldSum = sum; sum += p * regGamma; } return sum; }
From source file:edu.jhuapl.bsp.detector.OpenMath.java
public static double min(double[] in) { if (in != null) { double minvalue = Double.POSITIVE_INFINITY; for (int i = 0; i < in.length; i++) { minvalue = Math.min(in[i], minvalue); }/* w w w . j a v a 2 s. co m*/ return minvalue; } return Double.NEGATIVE_INFINITY; }
From source file:bacter.model.ACGCoalescent.java
@Override public double calculateLogP() { // Check whether conversion count exceeds bounds. if (acg.getTotalConvCount() < lowerCCBoundInput.get() || acg.getTotalConvCount() > upperCCBoundInput.get()) return Double.NEGATIVE_INFINITY; logP = calculateClonalFrameLogP();/*from w w w . ja v a2s.c o m*/ double poissonMean = rhoInput.get().getValue() * acg.getClonalFrameLength() * (acg.getTotalConvertibleSequenceLength() + acg.getConvertibleLoci().size() * (deltaInput.get().getValue() - 1.0)); // Probability of conversion count: if (poissonMean > 0.0) { logP += -poissonMean + acg.getTotalConvCount() * Math.log(poissonMean); // - GammaFunction.lnGamma(acg.getConvCount()+1); } else { if (acg.getTotalConvCount() > 0) logP = Double.NEGATIVE_INFINITY; } for (Locus locus : acg.getConvertibleLoci()) for (Conversion conv : acg.getConversions(locus)) logP += calculateConversionLogP(conv); // This N! takes into account the permutation invariance of // the individual conversions, and cancels with the N! in the // denominator of the Poissonian above. // logP += GammaFunction.lnGamma(acg.getConvCount() + 1); if (lowerCCBoundInput.get() > 0 || upperCCBoundInput.get() < Integer.MAX_VALUE) { try { logP -= new PoissonDistributionImpl(poissonMean).cumulativeProbability(lowerCCBoundInput.get(), upperCCBoundInput.get()); } catch (MathException e) { throw new RuntimeException("Error computing modification to ARG " + "prior density required by conversion number constraint."); } } return logP; }
From source file:com.opengamma.analytics.math.statistics.distribution.NonCentralChiSquaredDistribution.java
/** * {@inheritDoc}//from w w w. ja v a 2s .c o m */ @Override public double getCDF(final Double x) { Validate.notNull(x, "x"); if (x < 0) { return 0.0; } if ((_dofOverTwo + _lambdaOverTwo) > 1000) { return getFraserApproxCDF(x); } double regGammaStart = 0; final double halfX = x / 2.0; final double logX = Math.log(halfX); try { regGammaStart = Gamma.regularizedGammaP(_dofOverTwo + _k, halfX); } catch (final org.apache.commons.math.MathException ex) { throw new MathException(ex); } double sum = _pStart * regGammaStart; double oldSum = Double.NEGATIVE_INFINITY; double p = _pStart; double regGamma = regGammaStart; double temp; int i = _k; // first add terms below _k while (i > 0 && Math.abs(sum - oldSum) / sum > _eps) { i--; p *= (i + 1) / _lambdaOverTwo; temp = (_dofOverTwo + i) * logX - halfX - Gamma.logGamma(_dofOverTwo + i + 1); regGamma += Math.exp(temp); oldSum = sum; sum += p * regGamma; } p = _pStart; regGamma = regGammaStart; oldSum = Double.NEGATIVE_INFINITY; i = _k; while (Math.abs(sum - oldSum) / sum > _eps) { i++; p *= _lambdaOverTwo / i; temp = (_dofOverTwo + i - 1) * logX - halfX - Gamma.logGamma(_dofOverTwo + i); regGamma -= Math.exp(temp); oldSum = sum; sum += p * regGamma; } return sum; }
From source file:ffx.numerics.ModifiedBessel.java
/** * Returns Double.MAX_VALUE in place of Double.POSITIVE_INFINITY; Returns * Double.MIN_VALUE in place of Double.NEGATIVE_INFINITY * * @param x input parameter//from w w w. j a va 2 s. c o m * @return exp(x) */ private static double eToThe(double x) { double res = exp(x); if (res == Double.POSITIVE_INFINITY) { return Double.MAX_VALUE; } else if (res == Double.NEGATIVE_INFINITY) { return Double.MIN_VALUE; } return res; }
From source file:dr.evomodel.epidemiology.casetocase.periodpriors.NormalPeriodPriorDistribution.java
public double calculateLogPosteriorProbability(double newValue, double minValue) { double out = calculateLogPosteriorPredictiveProbability(newValue); if (minValue != Double.NEGATIVE_INFINITY) { out -= calculateLogPosteriorPredictiveCDF(minValue, true); }/*from w w w.ja v a 2 s . c om*/ logL += out; update(newValue); return out; }
From source file:org.jfree.experimental.chart.renderer.xy.VectorRenderer.java
/** * Returns the lower and upper bounds (range) of the x-values in the * specified dataset.//from ww w . j a va 2s . c om * * @param dataset the dataset (<code>null</code> permitted). * * @return The range (<code>null</code> if the dataset is <code>null</code> * or empty). */ public Range findDomainBounds(XYDataset dataset) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } double minimum = Double.POSITIVE_INFINITY; double maximum = Double.NEGATIVE_INFINITY; int seriesCount = dataset.getSeriesCount(); double lvalue; double uvalue; if (dataset instanceof VectorXYDataset) { VectorXYDataset vdataset = (VectorXYDataset) dataset; for (int series = 0; series < seriesCount; series++) { int itemCount = dataset.getItemCount(series); for (int item = 0; item < itemCount; item++) { double delta = vdataset.getDeltaXValue(series, item); if (delta < 0.0) { uvalue = vdataset.getXValue(series, item); lvalue = uvalue + delta; } else { lvalue = vdataset.getXValue(series, item); uvalue = lvalue + delta; } minimum = Math.min(minimum, lvalue); maximum = Math.max(maximum, uvalue); } } } else { for (int series = 0; series < seriesCount; series++) { int itemCount = dataset.getItemCount(series); for (int item = 0; item < itemCount; item++) { lvalue = dataset.getXValue(series, item); uvalue = lvalue; minimum = Math.min(minimum, lvalue); maximum = Math.max(maximum, uvalue); } } } if (minimum > maximum) { return null; } else { return new Range(minimum, maximum); } }
From source file:bb.mcmc.analysis.ESSConvergeStat.java
@Override protected double calculateEachStat(String key) { List<Double> listDouble = Arrays.asList(ArrayUtils.toObject(traceValues.get(key))); TraceCorrelation<Double> traceCorrelation = new TraceCorrelation<Double>(listDouble, TRACETYPE, stepSize); double stat = traceCorrelation.getESS(); if (Double.isNaN(stat)) { //Use two separate if to handle other NaN cases later if (traceCorrelation.getVariance() == 0) { stat = Double.NEGATIVE_INFINITY; System.err.println(STATISTIC_NAME + " could not be calculated for variable with id " + key + ". This is due to logged values being unchanged during the run");//. Check log file for details. "); }//from ww w. j ava 2 s . com } return stat; }