/** * {@inheritDoc} */ public synchronized long nextLong() { return wrapped.nextLong(); }
@Override public long nextLong() { return random.nextLong(); }
/** * Returns the next pseudorandom, uniformly distributed <code>long</code> * value from this random number generator's sequence. All * 2<font size="-1"><sup>64</sup></font> possible {@code long} values * should be produced with (approximately) equal probability. * * @return the next pseudorandom, uniformly distributed <code>long</code> *value from this random number generator's sequence */ @Override public long nextLong() { return randomGenerator.nextLong(); }
@Override public long nextLong() { return getRandomGenerator().nextLong(); }
/** {@inheritDoc} */ public long nextSecureLong(final long lower, final long upper) throws NumberIsTooLargeException { if (lower >= upper) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND, lower, upper, false); } final RandomGenerator rng = getSecRan(); final long max = (upper - lower) + 1; if (max <= 0) { // the range is too wide to fit in a positive long (larger than 2^63); as it covers // more than half the long range, we use directly a simple rejection method while (true) { final long r = rng.nextLong(); if (r >= lower && r <= upper) { return r; } } } else if (max < Integer.MAX_VALUE){ // we can shift the range and generate directly a positive int return lower + rng.nextInt((int) max); } else { // we can shift the range and generate directly a positive long return lower + nextLong(rng, max); } }
/** * Default implementation which randomly splits new data into train/test sets. * This handles the case where {@link #getTestFraction()} is not 0 or 1. * * @param newData data that has arrived in the current input batch * @return a {@link Pair} of train, test {@link RDD}s. */ protected Pair<JavaRDD<M>,JavaRDD<M>> splitNewDataToTrainTest(JavaRDD<M> newData) { RDD<M>[] testTrainRDDs = newData.rdd().randomSplit( new double[]{1.0 - testFraction, testFraction}, RandomManager.getRandom().nextLong()); return new Pair<>(newData.wrapRDD(testTrainRDDs[0]), newData.wrapRDD(testTrainRDDs[1])); }
/** {@inheritDoc} */ public long nextLong(final long lower, final long upper) throws NumberIsTooLargeException { if (lower >= upper) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND, lower, upper, false); } final long max = (upper - lower) + 1; if (max <= 0) { // the range is too wide to fit in a positive long (larger than 2^63); as it covers // more than half the long range, we use directly a simple rejection method final RandomGenerator rng = getRandomGenerator(); while (true) { final long r = rng.nextLong(); if (r >= lower && r <= upper) { return r; } } } else if (max < Integer.MAX_VALUE){ // we can shift the range and generate directly a positive int return lower + getRandomGenerator().nextInt((int) max); } else { // we can shift the range and generate directly a positive long return lower + nextLong(getRandomGenerator(), max); } }
/** * {@inheritDoc} */ public synchronized long nextLong() { return wrapped.nextLong(); }
/** * {@inheritDoc} */ public synchronized long nextLong() { return wrapped.nextLong(); }
public static ImmutableList<Long> generateDistinct(RandomGenerator rng, int size) { final Set<Long> numbers = newLinkedHashSet(); while (numbers.size() < size) { numbers.add(rng.nextLong()); } return ImmutableList.copyOf(numbers); }
static ImmutableList<Long> generateDistinct(RandomGenerator rng, int size) { final Set<Long> numbers = newLinkedHashSet(); while (numbers.size() < size) { numbers.add(rng.nextLong()); } return ImmutableList.copyOf(numbers); }
/** * Returns a random element from this ring * * @param rnd the source of randomness * @return random element from this ring */ public long randomElement(RandomGenerator rnd) { return modulus(rnd.nextLong()); }
@Override public long getSeed() { stateCheck(); return masterRandomGenerator.nextLong(); }
static double getValue(StochasticSupplier<Double> ed, RandomGenerator rng) { final double sample = ed.get(rng.nextLong()); checkArgument( sample >= 0d, "A StochasticSupplier used in a TimeSeries may not return negative " + "values, was: %s.", sample); return sample; } }
static SineIntensity create(SineIntensityBuilder b, long seed) { final RandomGenerator rng = new MersenneTwister(seed); final double amplitude = b.amplitudeSup.get(rng.nextLong()); final double frequency = b.frequencySup.get(rng.nextLong()); final double height = b.heightSup.get(rng.nextLong()); final double phaseShift = b.phaseShiftSup.get(rng.nextLong()); return new AutoValue_IntensityFunctions_SineIntensity(amplitude, frequency, height, phaseShift); } }
@Override public RandomGenerator sharedInstance(Class<?> clazz) { stateCheck(); if (!classRngMap.containsKey(clazz)) { final RandomGenerator rng = new UnmodifiableRandomGenerator( new MersenneTwister(masterRandomGenerator.nextLong())); classRngMap.put(clazz, rng); return rng; } return classRngMap.get(clazz); } }
NameManager(Long seed, String kronecker, String metric) { if (seed == null) { random = new Well44497b(); random.setSeed(this.seed = random.nextLong()); } else random = new Well44497b(this.seed = seed); kroneckerAndMetricNames[0] = kronecker; kroneckerAndMetricNames[1] = metric; }
@Override public void handleTimedEvent(AddVehicleEvent event, SimulatorAPI simulator) { final RoutePlanner rp = getRoutePlanner().get(simulator.getRandomGenerator() .nextLong()); final Communicator c = getCommunicator().get(simulator.getRandomGenerator() .nextLong()); simulator.register(new Truck(event.getVehicleDTO(), rp, c, getRouteAdjuster(), getLazyComputation())); }