Java Random Double randomDoubleArray(int len)

Here you can find the source of randomDoubleArray(int len)

Description

Produce an array of random numbers in [0:1].

License

Open Source License

Parameter

Parameter Description
len Length

Return

Array

Declaration

public static double[] randomDoubleArray(int len) 

Method Source Code

//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;
    }
}

Related

  1. randomDouble(double min, double max)
  2. randomDouble(double min, double max)
  3. randomDouble(int min, int max)
  4. randomDouble(int start, int end)
  5. randomDoubleArray(final int mDimensionality)
  6. randomDoubleBetween(double a, double b)
  7. randomDoubleOperand(Random rnd)
  8. randomFlip(double probTrue)
  9. randomIn(double in)