List of usage examples for java.lang Double parseDouble
public static double parseDouble(String s) throws NumberFormatException
From source file:dom.rootlocus.utils.Utils.java
public PolynomialFunction toPolynomialFunction(String[] coef) { double[] cf = new double[coef.length]; for (int i = 0; i < coef.length; i++) { cf[i] = Double.parseDouble(coef[i]); }/*from w w w . ja v a2 s.c o m*/ return new PolynomialFunction(cf); }
From source file:Evaluator.StatCalculator.java
public HashMap<String, Double> readValues(String firstFileName, String secondFileName) throws FileNotFoundException, IOException { HashMap<String, Double> runQidMap = new HashMap<>(); FileReader firstFileReader = new FileReader(new File(firstFileName)); BufferedReader firstBufferReader = new BufferedReader(firstFileReader); FileReader secondFileReader = new FileReader(new File(secondFileName)); BufferedReader secondBufferReader = new BufferedReader(secondFileReader); String firstFileLine = firstBufferReader.readLine(); String secondFileLine = secondBufferReader.readLine(); while (firstFileLine != null) { String st1[] = firstFileLine.split(" "); String st2[] = secondFileLine.split(" "); // runQidMap.put(st1[0], (Double.parseDouble(st1[1]) + Double.parseDouble(st2[1])) / 2); runQidMap.put(st1[0], (Double.parseDouble(st1[1]))); firstFileLine = firstBufferReader.readLine(); secondFileLine = secondBufferReader.readLine(); }/*w w w. j a v a2s . c o m*/ return runQidMap; }
From source file:evaluation.loadGenerator.randomVariable.Binomial.java
public Binomial(String[] parameters) { super(parameters); if (parameters.length != numberOfParameters) throw new RuntimeException(errorMessage); try {//from w ww. ja va 2s . c o m this.numberOfTrials = Integer.parseInt(parameters[0]); this.probabilityOfSuccess = Double.parseDouble(parameters[1]); // test: this.randomDataImpl.nextBinomial(numberOfTrials, probabilityOfSuccess); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(errorMessage); } }
From source file:br.ime.usp.aztec.maztec.MAZTECCommandLineParametersParser.java
@Override protected MAZTECParameters buildParameters(CommandLine options) { Builder builder = new MAZTECParameters.Builder(); if (options.hasOption('I')) { builder.improved();//w w w . j av a 2 s . c o m } if (options.hasOption('d')) { builder.decoding(); } return builder.withInput(new SignalParser(this.openInputGivenIn(options))) .withOutput(new WriterEncodingOutput(this.openOutputGivenIn(options))) .withMinimumThreshold(Double .parseDouble(options.getOptionValue('t', String.valueOf(MAZTECParameters.DEFAULT_T_MIN)))) .withMaximumThreshold(Double .parseDouble(options.getOptionValue('T', String.valueOf(MAZTECParameters.DEFAULT_T_MAX)))) .withInitialThreshold(Double.parseDouble( options.getOptionValue('0', String.valueOf(MAZTECParameters.DEFAULT_INITIAL_T)))) .withCriterionFunctionWeight(Double .parseDouble(options.getOptionValue('1', String.valueOf(MAZTECParameters.DEFAULT_C1)))) .withLastThresholdWeight(Double .parseDouble(options.getOptionValue('2', String.valueOf(MAZTECParameters.DEFAULT_C2)))) .build(); }
From source file:org.eda.fpsrv.StrTable.java
protected Double parseDouble(String sval) { try {//from w w w. jav a 2 s. c o m return Double.parseDouble(sval); } catch (Exception e) { return 0.0; } }
From source file:ch.aonyx.broker.ib.api.util.InputStreamUtils.java
public static final double readDouble(final InputStream inputStream) { final String string = readString(inputStream); return string == null ? 0 : Double.parseDouble(string); }
From source file:gamlss.utilities.TestingDistributions.java
private void twoParTest() { String fileName = "Data/distTest.csv"; CSVFileReader readData = new CSVFileReader(fileName); readData.readFile();/*from w w w . j a v a 2 s . c om*/ ArrayList<String> data = readData.storeValues; ArrayRealVector y = new ArrayRealVector(data.size()); ArrayRealVector mu = new ArrayRealVector(data.size()); ArrayRealVector sigma = new ArrayRealVector(data.size()); ArrayRealVector nu = new ArrayRealVector(data.size()); ArrayRealVector tau = new ArrayRealVector(data.size()); for (int i = 0; i < data.size(); i++) { String[] line = data.get(i).split(","); y.setEntry(i, Double.parseDouble(line[0])); mu.setEntry(i, Double.parseDouble(line[1])); sigma.setEntry(i, Double.parseDouble(line[2])); nu.setEntry(i, Double.parseDouble(line[3])); tau.setEntry(i, Double.parseDouble(line[4])); } double[] outA = new double[y.getDimension()]; String folder = "C:\\Users\\Daniil\\Desktop\\Gamlss_exp/outDistG.csv"; ArrayRealVector out = null; GA dist = new GA(); dist.setDistributionParameter(DistributionSettings.MU, mu); dist.setDistributionParameter(DistributionSettings.SIGMA, sigma); dist.setDistributionParameter(DistributionSettings.NU, nu); dist.setDistributionParameter(DistributionSettings.TAU, tau); //1 out = dist.firstDerivative(DistributionSettings.MU, y); MatrixFunctions.vectorWriteCSV(folder, out, false); //2 out = dist.secondDerivative(DistributionSettings.MU, y); MatrixFunctions.vectorWriteCSV(folder, out, true); //3 out = dist.firstDerivative(DistributionSettings.SIGMA, y); MatrixFunctions.vectorWriteCSV(folder, out, true); //4 out = dist.secondDerivative(DistributionSettings.SIGMA, y); MatrixFunctions.vectorWriteCSV(folder, out, true); //5 // out = dist.secondCrossDerivative(DistributionSettings.MU, DistributionSettings.SIGMA, y); // MatrixFunctions.vectorWriteCSV(folder, out, true); //6 for (int i = 0; i < y.getDimension(); i++) { outA[i] = dist.dGA(y.getEntry(i), mu.getEntry(i), sigma.getEntry(i), false); } MatrixFunctions.vectorWriteCSV(folder, new ArrayRealVector(outA, false), true); //7 for (int i = 0; i < y.getDimension(); i++) { outA[i] = dist.dGA(y.getEntry(i), mu.getEntry(i), sigma.getEntry(i), true); } MatrixFunctions.vectorWriteCSV(folder, new ArrayRealVector(outA, false), true); //8 for (int i = 0; i < y.getDimension(); i++) { outA[i] = dist.pGA(y.getEntry(i), mu.getEntry(i), sigma.getEntry(i), true, true); } MatrixFunctions.vectorWriteCSV(folder, new ArrayRealVector(outA, false), true); //9 for (int i = 0; i < y.getDimension(); i++) { outA[i] = dist.pGA(y.getEntry(i), mu.getEntry(i), sigma.getEntry(i), false, true); } MatrixFunctions.vectorWriteCSV(folder, new ArrayRealVector(outA, false), true); //10 for (int i = 0; i < y.getDimension(); i++) { outA[i] = dist.pGA(y.getEntry(i), mu.getEntry(i), sigma.getEntry(i), true, false); } MatrixFunctions.vectorWriteCSV(folder, new ArrayRealVector(outA, false), true); //11 for (int i = 0; i < y.getDimension(); i++) { outA[i] = dist.pGA(y.getEntry(i), mu.getEntry(i), sigma.getEntry(i), false, false); } MatrixFunctions.vectorWriteCSV(folder, new ArrayRealVector(outA, false), true); //12 for (int i = 0; i < y.getDimension(); i++) { // outA[i] = dist.qGA(y.getEntry(i), mu.getEntry(i), sigma.getEntry(i), true, true); } // MatrixFunctions.vectorWriteCSV(folder, new ArrayRealVector(outA, false), true); //13 for (int i = 0; i < y.getDimension(); i++) { // outA[i] = dist.qGA(y.getEntry(i), mu.getEntry(i), sigma.getEntry(i), false, true); } // MatrixFunctions.vectorWriteCSV(folder, new ArrayRealVector(outA, false), true); //14 for (int i = 0; i < y.getDimension(); i++) { outA[i] = dist.qGA(y.getEntry(i), mu.getEntry(i), sigma.getEntry(i), true, false); } MatrixFunctions.vectorWriteCSV(folder, new ArrayRealVector(outA, false), true); //15 for (int i = 0; i < y.getDimension(); i++) { outA[i] = dist.qGA(y.getEntry(i), mu.getEntry(i), sigma.getEntry(i), false, false); } MatrixFunctions.vectorWriteCSV(folder, new ArrayRealVector(outA, false), true); //16 for (int i = 0; i < y.getDimension(); i++) { outA[i] = dist.dGA(y.getEntry(i)); } // MatrixFunctions.vectorWriteCSV(folder, new ArrayRealVector(outA, false), true); //17 for (int i = 0; i < y.getDimension(); i++) { outA[i] = dist.pGA(y.getEntry(i)); } // MatrixFunctions.vectorWriteCSV(folder, new ArrayRealVector(outA, false), true); //18 for (int i = 0; i < y.getDimension(); i++) { outA[i] = dist.qGA(y.getEntry(i)); } // MatrixFunctions.vectorWriteCSV(folder, new ArrayRealVector(outA, false), true); System.out.println("Done !!!"); }
From source file:ip.ui.LearningParamsInputPanel.java
public double getMomentumFactor() throws EmptyInputFieldException { String momentumFactorParam = momentumFactorInput.getText(); if (StringUtils.isEmpty(momentumFactorParam)) { throw new EmptyInputFieldException(momentumFactorLabel.getText()); }//w ww . j a v a 2s . com return Double.parseDouble(momentumFactorParam); }
From source file:dk.nodes.webservice.parser.NJSON.java
static Integer toInteger(Object value) { if (value instanceof Integer) { return (Integer) value; } else if (value instanceof Number) { return ((Number) value).intValue(); } else if (value instanceof String) { try {//from w ww. j a v a 2 s .c om return (int) Double.parseDouble((String) value); } catch (NumberFormatException ignored) { } } return null; }