Example usage for org.apache.commons.math3.random RandomDataGenerator nextUniform

List of usage examples for org.apache.commons.math3.random RandomDataGenerator nextUniform

Introduction

In this page you can find the example usage for org.apache.commons.math3.random RandomDataGenerator nextUniform.

Prototype

public double nextUniform(double lower, double upper, boolean lowerInclusive)
        throws NumberIsTooLargeException, NotFiniteNumberException, NotANumberException 

Source Link

Document

Algorithm Description: if the lower bound is excluded, scales the output of Random.nextDouble(), but rejects 0 values (i.e., will generate another random double if Random.nextDouble() returns 0).

Usage

From source file:gdsc.smlm.model.StandardFluorophoreSequenceModel.java

private static int nextGeometric(RandomDataGenerator rand, double mean) {
    // Use a geometric distribution by sampling the floor from the exponential.
    // Geometric distribution where k { 0, 1, 2, ... }
    // See: http://en.wikipedia.org/wiki/Geometric_distribution#Related_distributions
    final double p = 1 / (1 + mean);
    return (int) Math.floor(Math.log(rand.nextUniform(0, 1, true)) / Math.log(1 - p));
}

From source file:com.cloudera.oryx.ml.param.ContinuousRange.java

/**
 * @param rdg random number generator to use
 * @return a hyperparameter value chosen uniformly at random from the range
 *///from   w w w  .j  a v a 2s .  co  m
@Override
public Double getRandomValue(RandomDataGenerator rdg) {
    if (max == min) {
        return min;
    }
    return rdg.nextUniform(min, max, true);
}