@Override public int nextInt() { return random.nextInt(); }
/** * {@inheritDoc} */ public synchronized int nextInt() { return wrapped.nextInt(); }
/** * {@inheritDoc} */ public synchronized int nextInt(int n) { return wrapped.nextInt(n); }
@Override public int nextInt(int n) { return random.nextInt(n); }
/** * Returns the next pseudorandom, uniformly distributed <code>int</code> * value from this random number generator's sequence. * All 2<font size="-1"><sup>32</sup></font> possible {@code int} values * should be produced with (approximately) equal probability. * * @return the next pseudorandom, uniformly distributed <code>int</code> * value from this random number generator's sequence */ @Override public int nextInt() { return randomGenerator.nextInt(); }
/** * Returns a pseudorandom, uniformly distributed {@code int} value * between 0 (inclusive) and the specified value (exclusive), drawn from * this random number generator's sequence. * * @param n the bound on the random number to be returned. Must be * positive. * @return a pseudorandom, uniformly distributed {@code int} * value between 0 (inclusive) and n (exclusive). * @throws IllegalArgumentException if n is not positive. */ @Override public int nextInt(int n) { return randomGenerator.nextInt(n); }
@Override public int nextInt(int n) { return getRandomGenerator().nextInt(n); }
/** * {@inheritDoc} * A uniform random pivot selection between begin and end indices * @return The index corresponding to a random uniformly selected * value between first and the last indices of the array slice * @throws MathIllegalArgumentException when indices exceeds range */ public int pivotIndex(final double[] work, final int begin, final int end) throws MathIllegalArgumentException { MathArrays.verifyValues(work, begin, end-begin); return begin + random.nextInt(end - begin - 1); }
@Override public int nextInt() { return getRandomGenerator().nextInt(); }
/** * Returns a representation of a random binary array of length <code>length</code>. * @param length length of the array * @return a random binary array of length <code>length</code> */ public static List<Integer> randomBinaryRepresentation(int length) { // random binary list List<Integer> rList= new ArrayList<Integer> (length); for (int j=0; j<length; j++) { rList.add(GeneticAlgorithm.getRandomGenerator().nextInt(2)); } return rList; }
@Override public Iterator<Tuple2<Integer,Integer>> call( Tuple2<Integer,Iterable<Integer>> userIDsAndItemIDs) { Integer userID = userIDsAndItemIDs._1(); Collection<Integer> positiveItemIDs = Sets.newHashSet(userIDsAndItemIDs._2()); int numPositive = positiveItemIDs.size(); Collection<Tuple2<Integer,Integer>> negative = new ArrayList<>(numPositive); List<Integer> allItemIDs = allItemIDsBC.value(); int numItems = allItemIDs.size(); // Sample about as many negative examples as positive for (int i = 0; i < numItems && negative.size() < numPositive; i++) { Integer itemID = allItemIDs.get(random.nextInt(numItems)); if (!positiveItemIDs.contains(itemID)) { negative.add(new Tuple2<>(userID, itemID)); } } return negative.iterator(); } });
@Override public Pair<String,String> generate(int id, RandomGenerator random) { if (LARGE_MESSAGE == null) { StringBuilder builder = new StringBuilder(largeMessageSize); for (int i = 0; i < largeMessageSize; i++) { builder.append((char) (' ' + random.nextInt('~' - ' ' + 1))); } LARGE_MESSAGE = builder.toString(); } return new Pair<>(null, LARGE_MESSAGE); } }
abstract Invocation makeInvocation(WebTarget target, String user, String item, String strength);
@Override public Pair<String,String> generate(int id, RandomGenerator random) { String userString = ALSUtilsTest.idToStringID(random.nextInt(numUsers)); String itemString = ALSUtilsTest.idToStringID(random.nextInt(numProducts)); int rating = random.nextInt(maxRating - minRating + 1) + minRating; String datum = userString + "," + itemString + "," + rating + "," + System.currentTimeMillis(); return new Pair<>(Integer.toString(id), datum); }
protected Population initRandomPopulation(BitsChromosomeHelper helper) { List<Chromosome> chromosomeList = Lists.newArrayListWithCapacity(populationSize); while (chromosomeList.size() < populationSize) { BitSet bitSetForSelection = new BitSet(helper.getLength()); //Initialize selection genes double totalSpace = 0; while (totalSpace < helper.spaceLimit) { int j = org.apache.commons.math3.genetics.GeneticAlgorithm.getRandomGenerator() .nextInt(helper.getLength()); if (!bitSetForSelection.get(j)) { totalSpace += helper.getCuboidSizeByBitIndex(j); bitSetForSelection.set(j); } } Chromosome chromosome = new BitsChromosome(bitSetForSelection, benefitPolicy.getInstance(), helper); chromosomeList.add(chromosome); } return new ElitisticListPopulation(chromosomeList, maxPopulationSize, 0.8); } }
@Override public Pair<String,String> generate(int id, RandomGenerator random) { int user = random.nextInt(numUsers); int randProduct = random.nextInt(numProducts); // Want product === user mod features int product = ((user % features) + (randProduct / features) * features) % numProducts; String datum = ALSUtilsTest.idToStringID(user) + "," + ALSUtilsTest.idToStringID(product) + ",1," + System.currentTimeMillis(); return new Pair<>(Integer.toString(id), datum); }
@Override public Pair<String,String> generate(int id, RandomGenerator random) { return new Pair<>(Integer.toString(id), id + "," + random.nextInt(100) + ',' + random.nextBoolean() + ',' + random.nextGaussian()); }
@Test public void testUnseededRandomState() { RandomGenerator generator = RandomManager.getUnseededRandom(); assertNotEquals(1553355631, generator.nextInt()); }