org.apache.commons.math3.random.RandomDataGenerator.nextUniform()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(91)

本文整理了Java中org.apache.commons.math3.random.RandomDataGenerator.nextUniform方法的一些代码示例,展示了RandomDataGenerator.nextUniform的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RandomDataGenerator.nextUniform方法的具体详情如下:
包路径:org.apache.commons.math3.random.RandomDataGenerator
类名称:RandomDataGenerator
方法名:nextUniform

RandomDataGenerator.nextUniform介绍

[英]Algorithm Description: 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).
[中]算法描述:缩放随机变量的输出。nextDouble(),但拒绝0值(即,如果random.nextDouble()返回0,将生成另一个随机双精度)。这是提供对称输出间隔所必需的(两个端点都不包括在内)。

代码示例

代码示例来源:origin: OryxProject/oryx

/**
 * @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);
}

代码示例来源:origin: org.apache.commons/commons-math3

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

代码示例来源:origin: org.apache.commons/commons-math3

/**
 * {@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);
}

代码示例来源:origin: org.apache.commons/commons-math3

/**
 * {@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);
}

代码示例来源:origin: org.apache.commons/commons-math3

/**
 * {@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);
}

代码示例来源:origin: Devskiller/jfairy

public double nextDouble(double min, double max) {
    return randomDataGenerator.nextUniform(min, max);
  }
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

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

代码示例来源:origin: org.ojbc.bundles.adapters/static-mock-adapter-osgi

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

代码示例来源:origin: com.cloudera.oryx/oryx-ml

/**
 * @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);
}

代码示例来源:origin: org.ojbc.bundles.adapters/static-mock-adapter-osgi

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

代码示例来源:origin: geogebra/geogebra

/**
 * {@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);
}

代码示例来源:origin: io.codearte.jfairy/jfairy

public double nextDouble(double min, double max) {
    return randomDataGenerator.nextUniform(min, max);
  }
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

/**
 * {@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);
}

代码示例来源:origin: org.ojbc.bundles.adapters/static-mock-adapter-osgi

public double getFine() {
  return randomGenerator.nextUniform(minFine, maxFine);
}

代码示例来源:origin: zitmen/thunderstorm

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

代码示例来源:origin: geogebra/geogebra

/**
 * {@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);
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

/**
 * {@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);
}

代码示例来源:origin: stackoverflow.com

RandomDataGenerator rdg = new RandomDataGenerator();
rdg.nextUniform(1.0, 900.0, true);

代码示例来源:origin: org.drools/jbpm-simulation

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

代码示例来源:origin: kiegroup/droolsjbpm-integration

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

相关文章

微信公众号

最新文章

更多