Here you can find the source of randomDoubleArray(int len)
Parameter | Description |
---|---|
len | Length |
public static double[] randomDoubleArray(int len)
//package com.java2s; /*/* w w w . jav a 2 s. c om*/ This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures Copyright (C) 2013 Ludwig-Maximilians-Universit?t M?nchen Lehr- und Forschungseinheit f?r Datenbanksysteme ELKI Development Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ import java.util.Random; public class Main { /** * Produce an array of random numbers in [0:1]. * * @param len Length * @return Array */ public static double[] randomDoubleArray(int len) { return randomDoubleArray(len, new Random()); } /** * Produce an array of random numbers in [0:1]. * * @param len Length * @param r Random generator * @return Array */ public static double[] randomDoubleArray(int len, Random r) { final double[] ret = new double[len]; for (int i = 0; i < len; i++) { ret[i] = r.nextDouble(); } return ret; } }