/** * @param rdg random number generator to use * @return a hyperparameter value chosen uniformly at random from the range */ @Override public Double getRandomValue(RandomDataGenerator rdg) { if (max == min) { return min; } return rdg.nextUniform(min, max, true); }
/** * Gets a uniformly distributed random value with mean = mu. * * @return random uniform value * @throws MathIllegalArgumentException if the underlying random generator thwrows one */ private double getNextUniform() throws MathIllegalArgumentException { return randomData.nextUniform(0, 2 * mu); }
/** * {@inheritDoc} * * <p> * <strong>Algorithm Description</strong>: scales the output of * Random.nextDouble(), but rejects 0 values (i.e., will generate another * random double if Random.nextDouble() returns 0). This is necessary to * provide a symmetric output interval (both endpoints excluded). * </p> */ public double nextUniform(double lower, double upper) throws NumberIsTooLargeException, NotFiniteNumberException, NotANumberException { return delegate.nextUniform(lower, upper); }
/** * {@inheritDoc} * * <p> * <strong>Algorithm Description</strong>: 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). * This is necessary to provide a symmetric output interval (both * endpoints excluded). * </p> * @since 3.0 */ public double nextUniform(double lower, double upper, boolean lowerInclusive) throws NumberIsTooLargeException, NotFiniteNumberException, NotANumberException { return delegate.nextUniform(lower, upper, lowerInclusive); }
/** * {@inheritDoc} * * <p> * <strong>Algorithm Description</strong>: scales the output of * Random.nextDouble(), but rejects 0 values (i.e., will generate another * random double if Random.nextDouble() returns 0). This is necessary to * provide a symmetric output interval (both endpoints excluded). * </p> * @throws NumberIsTooLargeException if {@code lower >= upper} * @throws NotFiniteNumberException if one of the bounds is infinite * @throws NotANumberException if one of the bounds is NaN */ public double nextUniform(double lower, double upper) throws NumberIsTooLargeException, NotFiniteNumberException, NotANumberException { return nextUniform(lower, upper, false); }
public double nextDouble(double min, double max) { return randomDataGenerator.nextUniform(min, max); } }
/** * Gets a uniformly distributed random value with mean = mu. * * @return random uniform value * @throws MathIllegalArgumentException if the underlying random generator thwrows one */ private double getNextUniform() throws MathIllegalArgumentException { return randomData.nextUniform(0, 2 * mu); }
/** * Generate a double value from the uniform distribution, evenly distributed between zero and the specified value * * @param max * the maximum value to generate * @return the generated value */ protected final double generateUniformDouble(double max) { return randomGenerator.nextUniform(0.0, max); }
/** * @param rdg random number generator to use * @return a hyperparameter value chosen uniformly at random from the range */ @Override public Double getRandomValue(RandomDataGenerator rdg) { if (max == min) { return min; } return rdg.nextUniform(min, max, true); }
/** * Conduct an "unfair" coin flip (you can make it fair by setting probability=.5) * * @param probability * the probability of a positive outcome * @return the outcome (true for positive) */ protected final boolean coinFlip(double probability) { return randomGenerator.nextUniform(0.0, 1.0) < probability; }
/** * {@inheritDoc} * * <p> * <strong>Algorithm Description</strong>: scales the output of * Random.nextDouble(), but rejects 0 values (i.e., will generate another * random double if Random.nextDouble() returns 0). This is necessary to * provide a symmetric output interval (both endpoints excluded). * </p> */ public double nextUniform(double lower, double upper) throws NumberIsTooLargeException, NotFiniteNumberException, NotANumberException { return delegate.nextUniform(lower, upper); }
public double nextDouble(double min, double max) { return randomDataGenerator.nextUniform(min, max); } }
/** * {@inheritDoc} * * <p> * <strong>Algorithm Description</strong>: scales the output of * Random.nextDouble(), but rejects 0 values (i.e., will generate another * random double if Random.nextDouble() returns 0). This is necessary to * provide a symmetric output interval (both endpoints excluded). * </p> */ public double nextUniform(double lower, double upper) throws NumberIsTooLargeException, NotFiniteNumberException, NotANumberException { return delegate.nextUniform(lower, upper); }
public double getFine() { return randomGenerator.nextUniform(minFine, maxFine); }
private double getNextUniform(double lower, double upper) { //return ((lower == upper) ? lower : rand.nextUniform(lower, upper)); if(lower == upper) { return lower; } else { try { return rand.nextUniform(lower, upper); } catch(Exception ex) { int a = 5; return a; } } }
/** * {@inheritDoc} * * <p> * <strong>Algorithm Description</strong>: 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). * This is necessary to provide a symmetric output interval (both * endpoints excluded). * </p> * @since 3.0 */ public double nextUniform(double lower, double upper, boolean lowerInclusive) throws NumberIsTooLargeException, NotFiniteNumberException, NotANumberException { return delegate.nextUniform(lower, upper, lowerInclusive); }
/** * {@inheritDoc} * * <p> * <strong>Algorithm Description</strong>: 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). * This is necessary to provide a symmetric output interval (both * endpoints excluded). * </p> * @since 3.0 */ public double nextUniform(double lower, double upper, boolean lowerInclusive) throws NumberIsTooLargeException, NotFiniteNumberException, NotANumberException { return delegate.nextUniform(lower, upper, lowerInclusive); }
RandomDataGenerator rdg = new RandomDataGenerator(); rdg.nextUniform(1.0, 900.0, true);
public long generateTime() { TimeUnit tu = SimulationUtils.getTimeUnit(data); long min = (long)SimulationUtils.asDouble(data.get(SimulationConstants.MIN)); min = timeUnit.convert(min, tu); long max = (long) SimulationUtils.asDouble(data.get(SimulationConstants.MAX)); max = timeUnit.convert(max, tu); if (max > min) { return (long) generator.nextUniform(min, max); } else { return min; } }
public long generateTime() { TimeUnit tu = SimulationUtils.getTimeUnit(data); long min = (long)SimulationUtils.asDouble(data.get(SimulationConstants.MIN)); min = timeUnit.convert(min, tu); long max = (long) SimulationUtils.asDouble(data.get(SimulationConstants.MAX)); max = timeUnit.convert(max, tu); if (max > min) { return (long) generator.nextUniform(min, max); } else { return min; } }