Example usage for java.util Random doubles

List of usage examples for java.util Random doubles

Introduction

In this page you can find the example usage for java.util Random doubles.

Prototype

public DoubleStream doubles(long streamSize) 

Source Link

Document

Returns a stream producing the given streamSize number of pseudorandom double values, each between zero (inclusive) and one (exclusive).

Usage

From source file:com.wormsim.utils.TrackedScalar.java

public static void main2(String[] args) {
    timerStart();/*from   w w  w  .  ja v a  2  s . com*/
    final int walker_no = 1024;
    final int iter_no = 100;
    final List<List<Double>> data = new ArrayList<>(walker_no);
    final Random rng = new Random();
    for (int i = 0; i < walker_no; i++) {
        data.add(rng.doubles(iter_no).map((d) -> logit(d)).boxed().collect(Collectors.toList()));
    }
    double B, W, var, R;
    timer("Generated Data");
    W = calcWithinVarianceA(data);
    timer("Time Taken");
    B = calcBetweenVarianceA(data);
    timer("Time Taken");
    var = calcVar(iter_no, B, W);
    R = calcR(iter_no, B, W);
    timer("Time Taken");
    W = calcWithinVarianceB(data);
    timer("Time Taken");
    B = calcBetweenVarianceB(data);
    timer("Time Taken");
    var = calcVar(iter_no, B, W);
    R = calcR(iter_no, B, W);
    timer("Time Taken");
}

From source file:org.mpetnuch.gauss.linearalgebra.blas3.JBlasLevel3Test.java

private static double[][] generateData(int m, int n) {
    final Random randomStream = new Random((long) m * n);
    final double[][] data = new double[m][];
    Arrays.setAll(data, value -> randomStream.doubles(n).toArray());
    return data;/*  www .  jav  a  2s.  c  o m*/
}