List of usage examples for java.lang Double toString
public static String toString(double d)
From source file:ch.unil.genescore.vegas.GeneDataFakePhenotype.java
public void processData() { if (fakePhenoAr_ == null) { //constructFakePhenotype(); //if (Settings.multipleOfPhenotype_>1) constructFakePhenotypeAr();// www. ja v a 2 s .c o m //writeFakePhenotype(); } for (Snp mySnp : snpList_) { //mySnp.recalcPvalsAndZscores(fakePheno_, fakePhenoMean_,fakePhenoSd_, myT); //mySnp.recalcPvalsAndZscoresDirect(fakePheno_); recalcPvalsAndZscoresMultipleTimes(mySnp); String writingString = Double.toString(mySnp.getZscore()); writerSnpScores.println(writingString); } cov_ = LinkageDisequilibrium.computeCorrelationMatrixMTJ(snpList_); setSnpScores(); }
From source file:com.clican.pluto.common.resource.MapResource.java
public void setDouble(String key, double val) { put(key, Double.toString(val)); }
From source file:desmoj.core.dist.ContDistErlang.java
/** * Returns the next Erlang distributed sample from this distribution. The * algorithm used is taken from DESMO-C from Thomas Schniewind [Schni98] * Volume 2, page 222, file realdist.cc. It has been adapted to Java and * extended to handle antithetic random numbers if antithetic mode is * switched on./*ww w . j av a 2 s .com*/ * * @return Double : The next Erlang distributed sample */ public Double sample() { double newSample = 0.0; // auxiliary variable for computing the sample for (int i = 1; i <= k; i++) { // iteration over order of Erlang number newSample += super.sample(); } newSample = newSample / k; incrementObservations(-(k - 1)); // super class was sampled k times, // reduce observations by k-1 so // that one Erlang // sample counts only as one // observation if (this.currentlySendTraceNotes()) this.traceLastSample(Double.toString(newSample)); return newSample; }
From source file:com.linkedin.pinot.core.operator.transform.function.BaseTransformFunctionTest.java
@BeforeClass public void setUp() throws Exception { FileUtils.deleteQuietly(new File(INDEX_DIR_PATH)); long currentTimeMs = System.currentTimeMillis(); for (int i = 0; i < NUM_ROWS; i++) { _intSVValues[i] = RANDOM.nextInt(); _longSVValues[i] = RANDOM.nextLong(); _floatSVValues[i] = RANDOM.nextFloat(); _doubleSVValues[i] = RANDOM.nextDouble(); _stringSVValues[i] = Double.toString(RANDOM.nextDouble()); int numValues = 1 + RANDOM.nextInt(MAX_NUM_MULTI_VALUES); _intMVValues[i] = new int[numValues]; for (int j = 0; j < numValues; j++) { _intMVValues[i][j] = 1 + RANDOM.nextInt(MAX_MULTI_VALUE); }/*from w w w . j a v a2s. c o m*/ // Time in the past year _timeValues[i] = currentTimeMs - RANDOM.nextInt(365 * 24 * 3600) * 1000L; } List<GenericRow> rows = new ArrayList<>(NUM_ROWS); for (int i = 0; i < NUM_ROWS; i++) { Map<String, Object> map = new HashMap<>(); map.put(INT_SV_COLUMN, _intSVValues[i]); map.put(LONG_SV_COLUMN, _longSVValues[i]); map.put(FLOAT_SV_COLUMN, _floatSVValues[i]); map.put(DOUBLE_SV_COLUMN, _doubleSVValues[i]); map.put(STRING_SV_COLUMN, _stringSVValues[i]); map.put(INT_MV_COLUMN, ArrayUtils.toObject(_intMVValues[i])); map.put(TIME_COLUMN, _timeValues[i]); GenericRow row = new GenericRow(); row.init(map); rows.add(row); } Schema schema = new Schema(); schema.addField(new DimensionFieldSpec(INT_SV_COLUMN, FieldSpec.DataType.INT, true)); schema.addField(new DimensionFieldSpec(LONG_SV_COLUMN, FieldSpec.DataType.LONG, true)); schema.addField(new DimensionFieldSpec(FLOAT_SV_COLUMN, FieldSpec.DataType.FLOAT, true)); schema.addField(new DimensionFieldSpec(DOUBLE_SV_COLUMN, FieldSpec.DataType.DOUBLE, true)); schema.addField(new DimensionFieldSpec(STRING_SV_COLUMN, FieldSpec.DataType.STRING, true)); schema.addField(new DimensionFieldSpec(INT_MV_COLUMN, FieldSpec.DataType.INT, false)); schema.addField(new TimeFieldSpec(TIME_COLUMN, FieldSpec.DataType.LONG, TimeUnit.MILLISECONDS)); SegmentGeneratorConfig config = new SegmentGeneratorConfig(schema); config.setOutDir(INDEX_DIR_PATH); config.setSegmentName(SEGMENT_NAME); SegmentIndexCreationDriverImpl driver = new SegmentIndexCreationDriverImpl(); driver.init(config, new GenericRowRecordReader(rows, schema)); driver.build(); IndexSegment indexSegment = Loaders.IndexSegment.load(new File(INDEX_DIR_PATH, SEGMENT_NAME), ReadMode.heap); Set<String> columnNames = indexSegment.getColumnNames(); _dataSourceMap = new HashMap<>(columnNames.size()); for (String columnName : columnNames) { _dataSourceMap.put(columnName, indexSegment.getDataSource(columnName)); } _projectionBlock = new ProjectionOperator(_dataSourceMap, new DocIdSetOperator(new MatchEntireSegmentOperator(NUM_ROWS), DocIdSetPlanNode.MAX_DOC_PER_CALL)) .nextBlock(); }
From source file:com.wormsim.tracking.TrackedDouble.java
@Override public String toPotentialScaleReductionString() { return Double.toString(this.getPotentialScaleReduction()); }
From source file:com.googlecode.fascinator.common.IndexAndPayloadComposite.java
/** * Gets the String value of the specified field. * //from w w w . ja va 2 s . c o m * <ul> * <li>Fields that are not found will always return null.</li> * <li>Single valued fields will return the value found.</li> * <li>Multi valued fields return all concatenated values (bracketed and * quoted) if more then one entry is found, otherwise it will be simply the * first entry.</li> * </ul> * * @param field : The field name to query * @return String : The value found, possibly null */ public String get(String field) { Object object = getPath(field); // giving up if (object == null) { return null; } // This node is an array if (object instanceof JSONArray) { List<String> array = JsonSimple.getStringList((JSONArray) object); if (array.size() == 1) { return array.get(0); } else { return "[\"" + StringUtils.join(array, "\", \"") + "\"]"; } } // Much simpler if (object instanceof String) { return (String) object; } // Some fields can be float/double such as "score" if (object instanceof Double) { return Double.toString((Double) object); } // Shouldn't occur in a valid Solr response return null; }
From source file:com.nordpos.device.csv.FileCSVInputOutput.java
@Override public void sendProduct(ProductIO product) throws DeviceInputOutputException { try {//from ww w .ja v a 2 s.co m List dataRecord = new ArrayList(); dataRecord.add(product.getCode()); dataRecord.add(product.getName()); dataRecord.add(Double.toString(product.getQuantity())); dataRecord.add(Double.toString(product.getPriceSell())); csvPrinter.printRecord(dataRecord); } catch (IOException ex) { throw new DeviceInputOutputException(ex); } }
From source file:com.cloudbase.datacommands.CBSearchCondition.java
/** * Creates a new search condition for geographical searches. This looks for documents within a given boundary box * defined by the coordinates of its North-Eastern and South-Western corners. * @param NECorner The coordinates for the north eastern corner * @param SWCorner The coordinates for the south western corner */// w w w . ja v a2 s .c om public CBSearchCondition(BlackBerryLocation NECorner, BlackBerryLocation SWCorner) { Vector box = new Vector(); Vector NECornerList = new Vector(); NECornerList.addElement(Double.toString((NECorner.getQualifiedCoordinates().getLatitude()))); NECornerList.addElement(Double.toString((NECorner.getQualifiedCoordinates().getLongitude()))); Vector SWCornerList = new Vector(); SWCornerList.addElement(Double.toString((SWCorner.getQualifiedCoordinates().getLatitude()))); SWCornerList.addElement(Double.toString((SWCorner.getQualifiedCoordinates().getLongitude()))); box.addElement(SWCornerList); box.addElement(NECornerList); Hashtable boxCondition = new Hashtable(); boxCondition.put("$box", box); Hashtable searchQuery = new Hashtable(); searchQuery.put("$within", boxCondition); this.setField("cb_location"); this.setOperator(CBSearchConditionOperator.CBOperatorEqual); this.setValue(searchQuery); this.limit = -1; this.setCommandType(CBDataAggregationCommandType.CBDataAggregationMatch); }
From source file:com.autsia.bracer.BracerParser.java
/** * Parses the math expression (complicated formula) and stores the result * * @param expression <code>String</code> input expression (math formula) * @throws <code>ParseException</code> if the input expression is not * correct * @since 3.0/*from w w w .j a v a2s . c om*/ */ public void parse(String expression) throws ParseException { /* cleaning stacks */ stackOperations.clear(); stackRPN.clear(); /* * make some preparations: remove spaces; handle unary + and -, handle * degree character */ expression = expression.replace(" ", "").replace("", "*" + Double.toString(Math.PI) + "/180") .replace("(-", "(0-").replace(",-", ",0-").replace("(+", "(0+").replace(",+", ",0+") .replace("true", "1").replace("false", "0").replace("or", "|").replace("and", "&"); if (expression.charAt(0) == '-' || expression.charAt(0) == '+') { expression = "0" + expression; } /* splitting input string into tokens */ StringTokenizer stringTokenizer = new StringTokenizer(expression, OPERATORS + SEPARATOR + "()", true); /* loop for handling each token - shunting-yard algorithm */ while (stringTokenizer.hasMoreTokens()) { String token = stringTokenizer.nextToken(); if (isSeparator(token)) { while (!stackOperations.empty() && !isOpenBracket(stackOperations.lastElement())) { stackRPN.push(stackOperations.pop()); } } else if (isOpenBracket(token)) { stackOperations.push(token); } else if (isCloseBracket(token)) { while (!stackOperations.empty() && !isOpenBracket(stackOperations.lastElement())) { stackRPN.push(stackOperations.pop()); } stackOperations.pop(); if (!stackOperations.empty() && isFunction(stackOperations.lastElement())) { stackRPN.push(stackOperations.pop()); } } else if (isNumber(token)) { if (token.equals(IMAGINARY)) { stackRPN.push(complexFormat.format(new Complex(0, 1))); } else if (token.contains(IMAGINARY)) { stackRPN.push(complexFormat.format(complexFormat.parse("0+" + token))); } else { stackRPN.push(token); } } else if (isOperator(token)) { while (!stackOperations.empty() && isOperator(stackOperations.lastElement()) && getPrecedence(token) <= getPrecedence(stackOperations.lastElement())) { stackRPN.push(stackOperations.pop()); } stackOperations.push(token); } else if (isFunction(token)) { stackOperations.push(token); } else { throw new ParseException("Unrecognized token: " + token, 0); } } while (!stackOperations.empty()) { stackRPN.push(stackOperations.pop()); } /* reverse stack */ Collections.reverse(stackRPN); }
From source file:com.userweave.module.methoden.questionnaire.page.report.question.freeanswer.FreeQuestionReportPanel.java
private void addNumber(String id, double number, final boolean isNumberFinal, boolean isVisible) { WebMarkupContainer row = new WebMarkupContainer(id + "Row") { @Override/*ww w. j a v a 2 s .c om*/ public boolean isVisible() { return isNumberFinal; } }; row.add(new Label(id, Double.toString(FormatUtils.round(number, 2)))); row.setVisible(isVisible); add(row); }