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:edu.rice.cs.bioinfo.programs.phylonet.algos.network.InferMLNetworkFromSequences.java
public List<Tuple<Network, Double>> inferNetwork(String[] gtTaxa, List<char[][]> sequences, Map<String, String> allele2species, RateModel gtrsm, double theta, int maxReticulations, int numSol) { if (_optimalNetworks == null) { _optimalNetworks = new Network[numSol]; _optimalScores = new double[numSol]; Arrays.fill(_optimalScores, Double.NEGATIVE_INFINITY); }//w w w.j a va 2 s. c o m List<Tuple<char[], Integer>> distinctSequences = summarizeSquences(sequences); String startingNetwork = _startNetwork.toString(); for (int i = 0; i < _numRuns; i++) { System.out.println("Run #" + i); DirectedGraphToGraphAdapter<String, PhyloEdge<String>> speciesNetwork = makeNetwork(startingNetwork); NetworkNeighbourhoodRandomWalkGenerator<DirectedGraphToGraphAdapter<String, PhyloEdge<String>>, String, PhyloEdge<String>> allNeighboursStrategy = new NetworkNeighbourhoodRandomWalkGenerator<DirectedGraphToGraphAdapter<String, PhyloEdge<String>>, String, PhyloEdge<String>>( _operationWeight, makeNode, makeEdge, _seed); AllNeighboursHillClimberFirstBetter<DirectedGraphToGraphAdapter<String, PhyloEdge<String>>, String, PhyloEdge<String>, Double> searcher = new AllNeighboursHillClimberFirstBetter<DirectedGraphToGraphAdapter<String, PhyloEdge<String>>, String, PhyloEdge<String>, Double>( allNeighboursStrategy); Func1<DirectedGraphToGraphAdapter<String, PhyloEdge<String>>, Double> scorer = getScoreFunction(gtTaxa, allele2species, distinctSequences, gtrsm, theta); Comparator<Double> comparator = getDoubleScoreComparator(); HillClimbResult<DirectedGraphToGraphAdapter<String, PhyloEdge<String>>, Double> result = searcher .search(speciesNetwork, scorer, comparator, _maxExaminations, maxReticulations, _maxFailure, _diameterLimit); // search starts here if (resultFile != null) { try { BufferedWriter bw = new BufferedWriter(new FileWriter(resultFile, true)); bw.append("Run #" + i + "\n"); for (int j = 0; j < _optimalNetworks.length; j++) { bw.append(_optimalScores[j] + ": " + _optimalNetworks[j].toString() + "\n"); } bw.newLine(); bw.close(); } catch (Exception e) { System.err.println(e.getMessage()); e.getStackTrace(); } } } List<Tuple<Network, Double>> resultList = new ArrayList<Tuple<Network, Double>>(); for (int i = 0; i < numSol; i++) { if (_optimalNetworks[i] != null) resultList.add(new Tuple<Network, Double>(_optimalNetworks[i], _optimalScores[i])); } //System.out.println("\n #Networks " + result.ExaminationsCount); return resultList; }
From source file:edu.isi.misd.scanner.network.modules.worker.processors.oceans.OceansLogisticRegressionProcessor.java
/** * Formats a double to a fixed (currently three) number of decimal places. *///from w w w .j a v a2s.c om public static double df(double a) { DecimalFormat f = new DecimalFormat(".000"); Double input = Double.valueOf(a); // check for special values so that they are not parsed if (input.equals(Double.NEGATIVE_INFINITY) || input.equals(Double.POSITIVE_INFINITY) || input.equals(Double.NaN)) { return input.doubleValue(); } return Double.parseDouble(f.format(input)); }
From source file:ml.shifu.shifu.core.binning.EqualPopulationBinning.java
/** * Generate data bin by expected bin number * // ww w . j a va2 s. c o m * @param toBinningNum * toBinningNum * @return list of data binning */ private List<Double> getDataBin(int toBinningNum) { List<Double> binBorders = new ArrayList<Double>(); binBorders.add(Double.NEGATIVE_INFINITY); double totalCnt = getTotalInHistogram(); // merge extra small bins // extra small bin means : binCount less than 3% of average bin count // binCount < ( total * (1/toBinningNum) * (3/100)) mergeExtraSmallBins(totalCnt, toBinningNum); if (this.currentHistogramUnitCnt <= toBinningNum) { // if the count of histogram unit is less than expected bin number // return each histogram unit as a bin. The boundary will be middle value // of every two histogram unit values convertHistogramUnitIntoBin(binBorders); return binBorders; } LinkNode<HistogramUnit> currStartPos = null; // To improve time performance sumCacheGen(); for (int j = 1; j < toBinningNum; j++) { double s = (j * totalCnt) / toBinningNum; LinkNode<HistogramUnit> pos = locateHistogram(s, currStartPos); if (pos == null || pos == currStartPos || pos.next() == null) { continue; } else { HistogramUnit chu = pos.data(); HistogramUnit nhu = pos.next().data(); // double d = s - sum(chu.getHval()); double d = s - sumCache.get(pos); if (d < 0) { double u = (chu.getHval() + nhu.getHval()) / 2; binBorders.add(u); currStartPos = pos; continue; } double a = nhu.getHcnt() - chu.getHcnt(); double b = 2 * chu.getHcnt(); double c = -2 * d; double z = 0.0; if (Double.compare(a, 0) == 0) { z = -1 * c / b; } else { z = (-1 * b + Math.sqrt(b * b - 4 * a * c)) / (2 * a); } double u = chu.getHval() + (nhu.getHval() - chu.getHval()) * z; binBorders.add(u); currStartPos = pos; } } return binBorders; }
From source file:iDynoOptimizer.MOEAFramework26.src.org.moeaframework.core.AdaptiveGridArchive.java
/** * Computes new lower and upper bounds and recalculates the densities of * each grid cell.// ww w .j a v a2s . c om */ protected void adaptGrid() { Arrays.fill(minimum, Double.POSITIVE_INFINITY); Arrays.fill(maximum, Double.NEGATIVE_INFINITY); Arrays.fill(density, 0); for (Solution solution : this) { for (int i = 0; i < problem.getNumberOfObjectives(); i++) { minimum[i] = Math.min(minimum[i], solution.getObjective(i)); maximum[i] = Math.max(maximum[i], solution.getObjective(i)); } } for (Solution solution : this) { density[findIndex(solution)]++; } }
From source file:com.algoTrader.service.SimulationServiceImpl.java
@SuppressWarnings("unchecked") private static String convertStatisticsToLongString(SimulationResultVO resultVO) { StringBuffer buffer = new StringBuffer(); buffer.append("execution time (min): " + (new DecimalFormat("0.00")).format(resultVO.getMins()) + LF); buffer.append("dataSet: " + dataSet + LF); double netLiqValue = resultVO.getNetLiqValue(); buffer.append("netLiqValue=" + twoDigitFormat.format(netLiqValue) + LF); List<MonthlyPerformanceVO> monthlyPerformanceVOs = resultVO.getMonthlyPerformanceVOs(); double maxDrawDownM = 0d; double bestMonthlyPerformance = Double.NEGATIVE_INFINITY; if (monthlyPerformanceVOs != null) { StringBuffer dateBuffer = new StringBuffer("month-year: "); StringBuffer performanceBuffer = new StringBuffer("MonthlyPerformance: "); for (MonthlyPerformanceVO monthlyPerformanceVO : monthlyPerformanceVOs) { maxDrawDownM = Math.min(maxDrawDownM, monthlyPerformanceVO.getValue()); bestMonthlyPerformance = Math.max(bestMonthlyPerformance, monthlyPerformanceVO.getValue()); dateBuffer.append(dateFormat.format(monthlyPerformanceVO.getDate())); performanceBuffer/* w w w . j av a2s . c om*/ .append(StringUtils.leftPad(twoDigitFormat.format(monthlyPerformanceVO.getValue() * 100), 6) + "% "); } buffer.append(dateBuffer.toString() + LF); buffer.append(performanceBuffer.toString() + LF); } PerformanceKeysVO performanceKeys = resultVO.getPerformanceKeysVO(); MaxDrawDownVO maxDrawDownVO = resultVO.getMaxDrawDownVO(); if (performanceKeys != null && maxDrawDownVO != null) { buffer.append("n=" + performanceKeys.getN()); buffer.append(" avgM=" + twoDigitFormat.format(performanceKeys.getAvgM() * 100) + PCNT); buffer.append(" stdM=" + twoDigitFormat.format(performanceKeys.getStdM() * 100) + PCNT); buffer.append(" avgY=" + twoDigitFormat.format(performanceKeys.getAvgY() * 100) + PCNT); buffer.append(" stdY=" + twoDigitFormat.format(performanceKeys.getStdY() * 100) + PCNT); buffer.append(" sharpRatio=" + twoDigitFormat.format(performanceKeys.getSharpRatio()) + LF); buffer.append("maxDrawDownM=" + twoDigitFormat.format(-maxDrawDownM * 100) + PCNT); buffer.append(" bestMonthlyPerformance=" + twoDigitFormat.format(bestMonthlyPerformance * 100) + PCNT); buffer.append(" maxDrawDown=" + twoDigitFormat.format(maxDrawDownVO.getAmount() * 100) + PCNT); buffer.append( " maxDrawDownPeriod=" + twoDigitFormat.format(maxDrawDownVO.getPeriod() / 86400000) + "days"); buffer.append( " colmarRatio=" + twoDigitFormat.format(performanceKeys.getAvgY() / maxDrawDownVO.getAmount())); } return buffer.toString(); }
From source file:com.luciddreamingapp.beta.util.audio.SimpleAudioAnalyser.java
/** * Handle audio input. This is called on the thread of the * parent surface./*from w ww .jav a2s.co m*/ * * @param buffer Audio data that was just read. */ private final void processAudio(short[] buffer) { // Process the buffer. While reading it, it needs to be locked. synchronized (buffer) { // Calculate the power now, while we have the input // buffer; this is pretty cheap. final int len = buffer.length; SignalPower.biasAndRange(buffer, len - inputBlockSize, inputBlockSize, biasRange); double power = SignalPower.calculatePowerDb(buffer, 0, len); if (power > 0) { power = 0; } else if (power < -100) { power = -100; } else if (power == Double.NEGATIVE_INFINITY) { power = -100; } //flip the DB reading to make it make more sense statPower.addValue(power); // float range = biasRange[1]; // //add range - bias to estimate the sound intensity statSound.addValue(range - biasRange[0]); // Tell the reader we're done with the buffer. buffer.notify(); } }
From source file:com.itemanalysis.psychometrics.measurement.DefaultItemScoring.java
/** * This method return the answer key for an item. the answer key is * the category code with the highest score values. For a multiple-choice * question it will return the response options with a score of, say, 1 * where all other scores are 0. For a polytomous item it will return a * plus sign to indicate increasing order and a minus sign to indicate * reverse order. jMetrik uses this method to populate a table with * the answer key./*from w w w .j a v a 2s .c om*/ * * @return answer key */ public String getAnswerKey() { // Category cat; double scoreValue = 0; double maxScore = Double.NEGATIVE_INFINITY; String answerKey = ""; if (binaryScoring()) { // for(Object o : categories.keySet()){ // cat = categories.get(o); // scoreValue = cat.scoreValue(); for (Object o : categoryMap.keySet()) { scoreValue = categoryMap.get(o).scoreValue(); if (scoreValue > maxScore) { maxScore = scoreValue; answerKey = o.toString(); } } } else { //determine if polytomous item is in ascending order or reverse order Set<Object> keySet = categoryMap.keySet(); Object[] obj = keySet.toArray(); Arrays.sort(obj); Category cat1 = categoryMap.get(obj[0]); Category cat2 = categoryMap.get(obj[obj.length - 1]); if (cat1.scoreValue() <= cat2.scoreValue()) { answerKey = "+";//ascending order double min = minimumPossibleScore(); if (min != 1) answerKey += (int) min; } else { answerKey = "-";//reverse order double max = maximumPossibleScore(); if (max != numberOfCategories()) answerKey += (int) max; } } return answerKey; }
From source file:io.warp10.continuum.gts.GTSOutliersHelper.java
/** * Applying Grubbs' test using mean/std or median/mad * @see http://www.itl.nist.gov/div898/handbook/eda/section3/eda35h1.htm * /*from w w w .j av a 2 s . co m*/ * @param gts * @param useMedian Should the test use median/mad instead of mean/std * @param alpha Significance level with which to accept or reject anomalies. Default is 0.05 * * @return anomalous_ticks * * @throws WarpScriptException */ public static List<Long> grubbsTest(GeoTimeSerie gts, boolean useMedian, double alpha) throws WarpScriptException { doubleCheck(gts); List<Long> anomalous_ticks = new ArrayList<Long>(); int N = gts.values; if (N < 3) { // no anomalous tick in this case return anomalous_ticks; } double[] musigma = madsigma(gts, useMedian); double m = musigma[0]; double std = musigma[1]; if (0.0D == std) { return anomalous_ticks; } double z = 0.0D; double max = Double.NEGATIVE_INFINITY; long suspicious_tick = 0L; for (int i = 0; i < N; i++) { z = Math.abs((gts.doubleValues[i] - m) / std); if (z > max) { max = z; suspicious_tick = gts.ticks[i]; } } // // Calculate critical value // double t = new TDistribution(N - 2).inverseCumulativeProbability(alpha / (2 * N)); // // Calculate threshold // double Ginf = (N - 1) * Math.abs(t) / Math.sqrt(N * (N - 2 + t * t)); // // Test // if (max > Ginf) { anomalous_ticks.add(suspicious_tick); } return anomalous_ticks; }
From source file:com.uphyca.stetho_realm.Database.java
private List<Object> flattenRows(Table table, int limit, boolean addRowIndex) { Util.throwIfNot(limit >= 0); final List<Object> flatList = new ArrayList<>(); long numColumns = table.getColumnCount(); final RowFetcher rowFetcher = RowFetcher.getInstance(); for (long row = 0; row < limit && row < table.size(); row++) { final RowWrapper rowData = RowWrapper.wrap(rowFetcher.getRow(table, row)); if (addRowIndex) { flatList.add(rowData.getIndex()); }/*ww w.ja va 2s . com*/ for (int column = 0; column < numColumns; column++) { switch (rowData.getColumnType(column)) { case INTEGER: flatList.add(rowData.getLong(column)); break; case BOOLEAN: flatList.add(rowData.getBoolean(column)); break; case STRING: flatList.add(rowData.getString(column)); break; case BINARY: flatList.add(rowData.getBinaryByteArray(column)); break; case FLOAT: final float aFloat = rowData.getFloat(column); if (Float.isNaN(aFloat)) { flatList.add("NaN"); } else if (aFloat == Float.POSITIVE_INFINITY) { flatList.add("Infinity"); } else if (aFloat == Float.NEGATIVE_INFINITY) { flatList.add("-Infinity"); } else { flatList.add(aFloat); } break; case DOUBLE: final double aDouble = rowData.getDouble(column); if (Double.isNaN(aDouble)) { flatList.add("NaN"); } else if (aDouble == Double.POSITIVE_INFINITY) { flatList.add("Infinity"); } else if (aDouble == Double.NEGATIVE_INFINITY) { flatList.add("-Infinity"); } else { flatList.add(aDouble); } break; case DATE: flatList.add(rowData.getDate(column)); break; case LINK: flatList.add(rowData.getLink(column)); break; case LINK_LIST: flatList.add(rowData.getLinkList(column)); break; default: flatList.add("unknown column type: " + rowData.getColumnType(column)); break; } } } if (limit < table.size()) { for (int column = 0; column < numColumns; column++) { flatList.add("{truncated}"); } } return flatList; }
From source file:com.rapidminer.operator.preprocessing.discretization.BinDiscretization.java
@Override public List<ParameterType> getParameterTypes() { List<ParameterType> types = super.getParameterTypes(); ParameterType type = new ParameterTypeInt(PARAMETER_NUMBER_OF_BINS, "Defines the number of bins which should be used for each attribute.", 2, Integer.MAX_VALUE, 2); type.setExpert(false);//from w w w. jav a 2 s.c om types.add(type); type = new ParameterTypeBoolean(PARAMETER_DEFINE_BOUNDARIES, "Define the boundraries for the bin calculation.", false); types.add(type); type = new ParameterTypeDouble(PARAMETER_MIN_VALUE, "The minimum value for the binning range.", Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, true); type.registerDependencyCondition( new BooleanParameterCondition(this, PARAMETER_DEFINE_BOUNDARIES, true, true)); types.add(type); type = new ParameterTypeDouble(PARAMETER_MAX_VALUE, "The maximum value for the binning range.", Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, true); type.registerDependencyCondition( new BooleanParameterCondition(this, PARAMETER_DEFINE_BOUNDARIES, true, true)); types.add(type); types.add(new ParameterTypeCategory(PARAMETER_RANGE_NAME_TYPE, "Indicates if long range names including the limits should be used.", DiscretizationModel.RANGE_NAME_TYPES, DiscretizationModel.RANGE_NAME_LONG)); type = new ParameterTypeBoolean(PARAMETER_AUTOMATIC_NUMBER_OF_DIGITS, "Indicates if the number of digits should be automatically determined for the range names.", true); type.registerDependencyCondition(new EqualTypeCondition(this, PARAMETER_RANGE_NAME_TYPE, DiscretizationModel.RANGE_NAME_TYPES, false, DiscretizationModel.RANGE_NAME_INTERVAL)); types.add(type); type = new ParameterTypeInt(PARAMETER_NUMBER_OF_DIGITS, "The minimum number of digits used for the interval names.", 1, Integer.MAX_VALUE, 3); type.registerDependencyCondition( new BooleanParameterCondition(this, PARAMETER_AUTOMATIC_NUMBER_OF_DIGITS, false, false)); types.add(type); return types; }