Tabnine Logo
RandomGenerator.nextDouble
Code IndexAdd Tabnine to your IDE (free)

How to use
nextDouble
method
in
org.apache.commons.math3.random.RandomGenerator

Best Java code snippets using org.apache.commons.math3.random.RandomGenerator.nextDouble (Showing top 20 results out of 315)

origin: org.apache.commons/commons-math3

/** Generate a random scalar with null mean and unit standard deviation.
 * <p>The number generated is uniformly distributed between -&sqrt;(3)
 * and +&sqrt;(3).</p>
 * @return a random scalar with null mean and unit standard deviation
 */
public double nextNormalizedDouble() {
  return SQRT3 * (2 * generator.nextDouble() - 1.0);
}
origin: org.apache.commons/commons-math3

/**
 * {@inheritDoc}
 */
public synchronized double nextDouble() {
  return wrapped.nextDouble();
}
origin: apache/mahout

@Override
public double nextDouble() {
 return random.nextDouble();
}
origin: org.apache.commons/commons-math3

  /** {@inheritDoc} */
  @Override
  public double sample()  {
    final double u = random.nextDouble();
    return u * upper + (1 - u) * lower;
  }
}
origin: org.apache.commons/commons-math3

 /**
 * Returns the next pseudorandom, uniformly distributed
 * <code>double</code> value between <code>0.0</code> and
 * <code>1.0</code> from this random number generator's sequence.
 *
 * @return  the next pseudorandom, uniformly distributed
 *  <code>double</code> value between <code>0.0</code> and
 *  <code>1.0</code> from this random number generator's sequence
 */
@Override
public double nextDouble() {
  return randomGenerator.nextDouble();
}
origin: deeplearning4j/nd4j

/**
 * Generates a random integer between the specified numbers
 *
 * @param begin the begin of the interval
 * @param end   the end of the interval
 * @return an int between begin and end
 */
public static int randomNumberBetween(double begin, double end, RandomGenerator rng) {
  if (begin > end)
    throw new IllegalArgumentException("Begin must not be less than end");
  return (int) begin + (int) (rng.nextDouble() * ((end - begin) + 1));
}
origin: apache/incubator-druid

 @Override
 public T sample()
 {
  final double randomValue = random.nextDouble();
  Integer valueIndex = probabilityRanges.floorEntry(randomValue).getValue();
  return normalizedPmf.get(valueIndex).getFirst();
 }
}
origin: OryxProject/oryx

Endpoint chooseEndpoint(RandomGenerator random) {
 double p = random.nextDouble();
 int i = 0;
 while (i < cumulativeProbs.length && p >= cumulativeProbs[i]) {
  i++;
 }
 return endpoints[i];
}
origin: org.apache.commons/commons-math3

/**
 * Initialize the membership matrix with random values.
 */
private void initializeMembershipMatrix() {
  for (int i = 0; i < points.size(); i++) {
    for (int j = 0; j < k; j++) {
      membershipMatrix[i][j] = random.nextDouble();
    }
    membershipMatrix[i] = MathArrays.normalizeArray(membershipMatrix[i], 1.0);
  }
}
origin: org.apache.commons/commons-math3

  /** {@inheritDoc} */
  @Override
  public double sample()  {
    final double n = random.nextDouble();
    return scale / FastMath.pow(n, 1 / shape);
  }
}
origin: org.apache.commons/commons-math3

/**
 * {@inheritDoc}
 *
 * The default implementation uses the
 * <a href="http://en.wikipedia.org/wiki/Inverse_transform_sampling">
 * inversion method</a>.
 */
public int sample() {
  return inverseCumulativeProbability(random.nextDouble());
}
origin: org.apache.commons/commons-math3

/**
 * {@inheritDoc}
 *
 * The default implementation uses the
 * <a href="http://en.wikipedia.org/wiki/Inverse_transform_sampling">
 * inversion method.
 * </a>
 */
public double sample() {
  return inverseCumulativeProbability(random.nextDouble());
}
origin: deeplearning4j/nd4j

@Override
public double nextDouble() {
  return getRandomGenerator().nextDouble();
}
origin: org.apache.commons/commons-math3

/**
 * Generates a representation corresponding to a random permutation of
 * length l which can be passed to the RandomKey constructor.
 *
 * @param l length of the permutation
 * @return representation of a random permutation
 */
public static final List<Double> randomPermutation(final int l) {
  List<Double> repr = new ArrayList<Double>(l);
  for (int i=0; i<l; i++) {
    repr.add(GeneticAlgorithm.getRandomGenerator().nextDouble());
  }
  return repr;
}
origin: apache/kylin

  private Chromosome rouletteWheel(final List<Chromosome> chromosomes, final double totalFitness) {
    double rnd = (GeneticAlgorithm.getRandomGenerator().nextDouble() * totalFitness);
    double runningScore = 0;
    for (Chromosome o : chromosomes) {
      if (rnd >= runningScore && rnd <= runningScore + o.getFitness()) {
        return o;
      }
      runningScore += o.getFitness();
    }
    return null;
  }
}
origin: OryxProject/oryx

@Override
public Pair<String, String> generate(int id, RandomGenerator random) {
 boolean positive = id % 2 != 0;
 String target = positive ? "banana" : "apple";
 // 10% chance of wrong predictor
 String predictor = (positive ^ (random.nextDouble() < 0.1)) ? "yellow" : "red";
 return new Pair<>(null, predictor + "," + target);
}
origin: org.apache.commons/commons-math3

/**
 * {@inheritDoc}
 *
 * @throws MathIllegalArgumentException if <code>original</code> is not a {@link RandomKey} instance
 */
public Chromosome mutate(final Chromosome original) throws MathIllegalArgumentException {
  if (!(original instanceof RandomKey<?>)) {
    throw new MathIllegalArgumentException(LocalizedFormats.RANDOMKEY_MUTATION_WRONG_CLASS,
                        original.getClass().getSimpleName());
  }
  RandomKey<?> originalRk = (RandomKey<?>) original;
  List<Double> repr = originalRk.getRepresentation();
  int rInd = GeneticAlgorithm.getRandomGenerator().nextInt(repr.size());
  List<Double> newRepr = new ArrayList<Double> (repr);
  newRepr.set(rInd, GeneticAlgorithm.getRandomGenerator().nextDouble());
  return originalRk.newFixedLengthChromosome(newRepr);
}
origin: OryxProject/oryx

 @Override
 public Pair<String,String> generate(int id, RandomGenerator random) {
  List<String> elements = new ArrayList<>(numberOfDimensions);
  for (int i = 0; i < numberOfDimensions; i++) {
   double d = random.nextDouble();
   elements.add(Double.toString(d));
  }
  return new Pair<>(Integer.toString(id), TextUtils.joinDelimited(elements, ','));
 }
}
origin: OryxProject/oryx

@Override
public Pair<String,String> generate(int id, RandomGenerator random) {
 List<String> elements = new ArrayList<>(n + 2);
 elements.add(Integer.toString(id));
 boolean positive = true;
 for (int i = 0; i < n; i++) {
  double d = random.nextDouble();
  if (d < 0.5) {
   positive = false;
  }
  elements.add(Double.toString(d));
 }
 elements.add(Boolean.toString(positive));
 return new Pair<>(Integer.toString(id), TextUtils.joinDelimited(elements, ','));
}
origin: OryxProject/oryx

@Ignore
@Test
public void testRandomState() {
 RandomGenerator generator = RandomManager.getRandom();
 double unseededValue = generator.nextDouble();
 RandomManager.useTestSeed();
 double seededValue = generator.nextDouble();
 assertNotEquals(unseededValue, seededValue);
 assertEquals(seededValue, RandomManager.getRandom().nextDouble());
}
org.apache.commons.math3.randomRandomGeneratornextDouble

Javadoc

Returns the next pseudorandom, uniformly distributed double value between 0.0 and 1.0 from this random number generator's sequence.

Popular methods of RandomGenerator

  • nextInt
    Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified valu
  • nextLong
    Returns the next pseudorandom, uniformly distributed long value from this random number generator's
  • setSeed
    Sets the seed of the underlying random number generator using anint array seed. Sequences of values
  • nextBoolean
    Returns the next pseudorandom, uniformly distributedboolean value from this random number generator'
  • nextFloat
    Returns the next pseudorandom, uniformly distributed float value between 0.0 and 1.0 from this rand
  • nextGaussian
    Returns the next pseudorandom, Gaussian ("normally") distributeddouble value with mean 0.0 and stand
  • nextBytes
    Generates random bytes and places them into a user-supplied byte array. The number of random bytes p
  • <init>

Popular in Java

  • Running tasks concurrently on multiple threads
  • onRequestPermissionsResult (Fragment)
  • getSystemService (Context)
  • setScale (BigDecimal)
  • Kernel (java.awt.image)
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • JTable (javax.swing)
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now