List of usage examples for java.lang Double valueOf
@HotSpotIntrinsicCandidate public static Double valueOf(double d)
From source file:com.eviware.loadui.impl.statistics.db.util.TypeConverter.java
public static Object stringToObject(String value, Class<? extends Object> type) throws IOException { if (value == null) { return null; } else if (type == Long.class) { return Long.valueOf(value); } else if (type == Integer.class) { return Integer.valueOf(value); } else if (type == Double.class) { return Double.valueOf(value); } else if (type == Float.class) { return Float.valueOf(value); } else if (type == Boolean.class) { return Boolean.valueOf(value); } else if (type == String.class) { return value; } else if (type == Date.class) { Date d = new Date(); d.setTime(Long.valueOf(value)); return d; } else if (type == BufferedImage.class) { return imageFromByteArray(Base64.decodeBase64(value)); } else {/*ww w. java 2s .c o m*/ try { type.asSubclass(Serializable.class); return base64ToObject(value); } catch (Exception e) { return value; } } }
From source file:com.mauersu.util.redis.DefaultTypedTuple.java
@Override public int compareTo(TypedTuple<V> o) { if (o == null) { return compareTo(Double.valueOf(0)); }// www . j ava 2 s. co m return compareTo(o.getScore()); }
From source file:de.tudarmstadt.ukp.experiments.argumentation.convincingness.svmlib.regression.SVMLibRegressionExperimentRunner.java
@Override public void runCrossValidation(File dataDir) throws IOException { Set<SinglePrediction> allPredictions = new HashSet<SinglePrediction>(); List<File> files = new ArrayList<File>(FileUtils.listFiles(dataDir, new String[] { "libsvm.txt" }, false)); for (File testFile : files) { // create training files from the rest Set<File> trainingFiles = new HashSet<File>(files); trainingFiles.remove(testFile);// www .ja v a 2s. c om // System.out.println("Training files: " + trainingFiles); System.out.println("Training files size: " + trainingFiles.size()); System.out.println("Test file: " + testFile); Set<SinglePrediction> predictions = runSingleFold(testFile, new ArrayList<File>(trainingFiles)); allPredictions.addAll(predictions); } List<SinglePrediction> predictions = new ArrayList<SinglePrediction>(allPredictions); double[][] matrix = new double[predictions.size()][]; for (int i = 0; i < predictions.size(); i++) { SinglePrediction prediction = predictions.get(i); matrix[i] = new double[2]; matrix[i][0] = Double.valueOf(prediction.getGold()); matrix[i][1] = Double.valueOf(prediction.getPrediction()); } PearsonsCorrelation pearsonsCorrelation = new PearsonsCorrelation(matrix); try { double pValue = pearsonsCorrelation.getCorrelationPValues().getEntry(0, 1); double correlation = pearsonsCorrelation.getCorrelationMatrix().getEntry(0, 1); System.out.println("Correlation: " + correlation); System.out.println("p-Value: " + pValue); System.out.println("Samples: " + predictions.size()); SpearmansCorrelation sc = new SpearmansCorrelation(new Array2DRowRealMatrix(matrix)); double pValSC = sc.getRankCorrelation().getCorrelationPValues().getEntry(0, 1); double corrSC = sc.getCorrelationMatrix().getEntry(0, 1); System.out.println("Spearman: " + corrSC + ", p-Val " + pValSC); } catch (MathException e) { throw new IOException(e); } }
From source file:liveDriftCorrectionGUI.java
/** * Creates new form liveDriftCorrectionGUI *//*from ww w.j a v a 2 s . c o m*/ public liveDriftCorrectionGUI(CMMCore core, ScriptInterface app) { app_ = app; core_ = core; studio_ = MMStudioMainFrame.getInstance(); initComponents(); pixelSizeUm_ = Double.valueOf(PixelSizeEdit.getText()); MAX_MOVE_TOLER = Double.valueOf(MaxMoveToler.getText()); DAMPING = Double.valueOf(Damping.getText()); setVisible(true); }
From source file:com.mgmtp.perfload.perfalyzer.binning.PerfMonBinningStrategy.java
@Override public void binData(final Scanner scanner, final WritableByteChannel destChannel) throws IOException { while (scanner.hasNextLine()) { String line = scanner.nextLine(); tokenizer.reset(line);//from w w w. ja va 2s. c o m List<String> tokenList = tokenizer.getTokenList(); if (typeConfig == null) { String type = tokenList.get(1); typeConfig = PerfMonTypeConfig.fromString(type); } try { long timestampMillis = Long.parseLong(tokenList.get(0)); Double value = Double.valueOf(tokenList.get(2)); binManager.addValue(timestampMillis, value); } catch (NumberFormatException ex) { log.error("Could not parse value {}. Line in perfMon file might be incomplete. Ignoring it.", ex); } } binManager.toCsv(destChannel, "seconds", typeConfig.getHeader(), intNumberFormat, typeConfig.getAggregationType()); }
From source file:net.anthonypoon.ngram.correlation.CorrelationReducer.java
@Override protected void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException { TreeMap<String, Double> currElement = new TreeMap(); for (Text val : values) { String[] strArray = val.toString().split("\t"); currElement.put(strArray[0], Double.valueOf(strArray[1])); }/*from w w w.j av a 2 s.c om*/ double[] currElementPrimitve = new double[upbound - lowbound + 1]; for (Integer i = 0; i <= upbound - lowbound; i++) { if (currElement.containsKey(String.valueOf(lowbound + i - lag))) { currElementPrimitve[i] = currElement.get(String.valueOf(lowbound + i - lag)); } else { currElementPrimitve[i] = 0; } } for (Map.Entry<String, TreeMap<String, Double>> pair : corrTargetArray.entrySet()) { double[] targetElemetPrimitive = new double[upbound - lowbound + 1]; for (Integer i = 0; i <= upbound - lowbound; i++) { if (pair.getValue().containsKey(String.valueOf(lowbound + i))) { targetElemetPrimitive[i] = pair.getValue().get(String.valueOf(lowbound + i)); } else { targetElemetPrimitive[i] = 0; } } Double correlation = new PearsonsCorrelation().correlation(targetElemetPrimitive, currElementPrimitve); if (correlation > threshold) { NumberFormat formatter = new DecimalFormat("#0.000"); context.write(key, new Text(pair.getKey() + "\t" + formatter.format(correlation))); } } }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.others.CumulativeCurveChart.java
public DatasetMap calculateValue() throws Exception { logger.debug("IN"); String res = DataSetAccessFunctions.getDataSetResultFromId(profile, getData(), parametersObject); SourceBean sbRows = SourceBean.fromXMLString(res); SourceBean sbRow = (SourceBean) sbRows.getAttribute("ROW"); List listAtts = sbRow.getContainedAttributes(); DefaultKeyedValues keyedValues = new DefaultKeyedValues(); for (Iterator iterator = listAtts.iterator(); iterator.hasNext();) { SourceBeanAttribute att = (SourceBeanAttribute) iterator.next(); String name = att.getKey(); String valueS = (String) att.getValue(); //try Double and Integer Conversion Double valueD = null;// ww w . j av a 2 s . c o m try { valueD = Double.valueOf(valueS); } catch (Exception e) { } Integer valueI = null; if (valueD == null) { valueI = Integer.valueOf(valueS); } if (name != null && valueD != null) { keyedValues.addValue(name, valueD); } else if (name != null && valueI != null) { keyedValues.addValue(name, valueI); } } keyedValues.sortByValues(sortOrder); //let user choose KeyedValues cumulative = DataUtilities.getCumulativePercentages(keyedValues); CategoryDataset dataset = DatasetUtilities.createCategoryDataset("Languages", keyedValues); CategoryDataset dataset2 = DatasetUtilities.createCategoryDataset("Cumulative", cumulative); logger.debug("OUT"); DatasetMap datasets = new DatasetMap(); datasets.addDataset("1", dataset); datasets.addDataset("2", dataset2); return datasets; }
From source file:es.us.isa.sedl.module.statcharts.renderer.HighChartsRenderer.java
private String[][] generateNormalDistribution(HistogramResult histogramResult) { Integer total = 0;/*from w w w . j a va2 s.c o m*/ for (String value : histogramResult.getCounts()) total += Integer.valueOf(value); Double mean = Double.valueOf(histogramResult.getMean()); Double sigma = Double.valueOf(histogramResult.getSigma()); NormalDistribution normal = new NormalDistribution(mean, sigma); Double[] xPoints = { -3.2807020192309, -3.0425988742109, -2.8044957291909, -2.5663925841709, -2.3282894391509, -2.0901862941309, -1.8520831491109, -1.6139800040909, -1.3758768590709, -1.1377737140509, -0.89967056903087, -0.66156742401087, -0.42346427899086, -0.18536113397085, 0.052742011049155, 0.29084515606916, 0.52894830108917, 0.76705144610918, 1.0051545911292, 1.2432577361492, 1.4813608811692, 1.7194640261892, 1.9575671712092, 2.1956703162292, 2.4337734612492, 2.6718766062692, 2.9099797512892, 3.1480828963092 }; String[][] result = new String[xPoints.length][2]; for (int i = 0; i < xPoints.length; i++) { result[i][0] = String.valueOf(mean + xPoints[i] * sigma); result[i][1] = String.valueOf(normal.density(mean + xPoints[i] * sigma) * total); } return result; }
From source file:com.handu.open.dubbo.monitor.controller.StatisticsController.java
@RequestMapping() public String index(@ModelAttribute DubboInvoke dubboInvoke, Model model) { // Set default Search Date if (dubboInvoke.getInvokeDate() == null && dubboInvoke.getInvokeDateFrom() == null && dubboInvoke.getInvokeDateTo() == null) { dubboInvoke.setInvokeDate(new Date()); }// w ww .j av a 2 s.c om //?Service List<String> methods = dubboMonitorService.getMethodsByService(dubboInvoke); List<DubboInvoke> dubboInvokes; List<DubboStatistics> dubboStatisticses = new ArrayList<DubboStatistics>(); DubboStatistics dubboStatistics; for (String method : methods) { dubboStatistics = new DubboStatistics(); dubboStatistics.setMethod(method); dubboInvoke.setMethod(method); dubboInvoke.setType("provider"); dubboInvokes = dubboMonitorService.countDubboInvokeInfo(dubboInvoke); for (DubboInvoke di : dubboInvokes) { if (di == null) { continue; } dubboStatistics.setProviderSuccess(di.getSuccess()); dubboStatistics.setProviderFailure(di.getFailure()); dubboStatistics.setProviderAvgElapsed(di.getSuccess() != 0 ? Double.valueOf(String.format("%.4f", di.getElapsed() / di.getSuccess())) : 0); dubboStatistics.setProviderMaxElapsed(di.getMaxElapsed()); dubboStatistics.setProviderMaxConcurrent(di.getMaxConcurrent()); } dubboInvoke.setType("consumer"); dubboInvokes = dubboMonitorService.countDubboInvokeInfo(dubboInvoke); for (DubboInvoke di : dubboInvokes) { if (di == null) { continue; } dubboStatistics.setConsumerSuccess(di.getSuccess()); dubboStatistics.setConsumerFailure(di.getFailure()); dubboStatistics.setConsumerAvgElapsed(di.getSuccess() != 0 ? Double.valueOf(String.format("%.4f", di.getElapsed() / di.getSuccess())) : 0); dubboStatistics.setConsumerMaxElapsed(di.getMaxElapsed()); dubboStatistics.setConsumerMaxConcurrent(di.getMaxConcurrent()); } dubboStatisticses.add(dubboStatistics); } model.addAttribute("rows", dubboStatisticses); model.addAttribute("service", dubboInvoke.getService()); return "service/statistics"; }
From source file:org.lightadmin.core.util.NumberUtils.java
@SuppressWarnings("unchecked") public static <T extends Number> T convertNumberToTargetClass(Number number, Class<T> targetClass) throws IllegalArgumentException { Assert.notNull(number, "Number must not be null"); Assert.notNull(targetClass, "Target class must not be null"); if (targetClass.isInstance(number)) { return (T) number; } else if (targetClass.equals(byte.class)) { long value = number.longValue(); if (value < Byte.MIN_VALUE || value > Byte.MAX_VALUE) { raiseOverflowException(number, targetClass); }//from ww w .ja v a 2s. c o m return (T) new Byte(number.byteValue()); } else if (targetClass.equals(short.class)) { long value = number.longValue(); if (value < Short.MIN_VALUE || value > Short.MAX_VALUE) { raiseOverflowException(number, targetClass); } return (T) new Short(number.shortValue()); } else if (targetClass.equals(int.class)) { long value = number.longValue(); if (value < Integer.MIN_VALUE || value > Integer.MAX_VALUE) { raiseOverflowException(number, targetClass); } return (T) new Integer(number.intValue()); } else if (targetClass.equals(long.class)) { return (T) new Long(number.longValue()); } else if (targetClass.equals(float.class)) { return (T) Float.valueOf(number.toString()); } else if (targetClass.equals(double.class)) { return (T) Double.valueOf(number.toString()); } else { return org.springframework.util.NumberUtils.convertNumberToTargetClass(number, targetClass); } }