Java Utililty Methods Random Double

List of utility methods to do Random Double

Description

The list of methods to do Random Double are organized into topic(s).

Method

double[]randomDoubleArray(int len)
Produce an array of random numbers in [0:1].
return randomDoubleArray(len, new Random());
doublerandomDoubleBetween(double a, double b)
random Double Between
return (Math.random() * (b - a) + a);
doublerandomDoubleOperand(Random rnd)
random Double Operand
switch (rnd.nextInt(3)) {
case 0:
    return rnd.nextDouble();
case 1:
    return rnd.nextGaussian();
default:
    return Double.longBitsToDouble(rnd.nextLong());
booleanrandomFlip(double probTrue)
random Flip
return Math.random() <= probTrue;
doublerandomIn(double in)
random In
return (double) (Math.random() * in);
voidrandomInitialize(double[] base)
random Initialize
for (int i = 0; i < base.length; i++) {
    base[i] = Math.random() / 10000;
doublerandomInRange(double min, double max)
random In Range
return Math.random() < 0.5 ? ((1 - Math.random()) * (max - min) + min)
        : (Math.random() * (max - min) + min);
booleanrandomPercent(double percent)
random Percent
return (Math.random() * 100.0) <= percent;
doublerandomRange(double min, double max)
Returns a pseudorandom double within the given range.
return min + (Math.random() * ((max - min) + 1));
doublerandRealUniform(double minrange, double maxrange)
Generates a random real number in the given range.
return minrange + (Math.random() * (maxrange - minrange));