375 |
|
* may, and typically does, vary across program invocations. |
376 |
|
*/ |
377 |
|
public SplittableRandom() { // emulate defaultGen.split() |
378 |
< |
long s = defaultGen.getAndAdd(2 * GOLDEN_GAMMA); |
378 |
> |
long s = defaultGen.getAndAdd(GOLDEN_GAMMA << 1); |
379 |
|
this.seed = mix64(s); |
380 |
|
this.gamma = mixGamma(s + GOLDEN_GAMMA); |
381 |
|
} |
531 |
|
} |
532 |
|
|
533 |
|
/** |
534 |
– |
* Generates a pseudorandom number with the indicated number of |
535 |
– |
* bits. Unlike in superclass {@link Random}, this method is never |
536 |
– |
* internally called or used by any other publicly accessible |
537 |
– |
* method. |
538 |
– |
* |
539 |
– |
* @param bits random bits |
540 |
– |
* @return the next pseudorandom value from this random number |
541 |
– |
* generator's sequence |
542 |
– |
*/ |
543 |
– |
protected int next(int bits) { |
544 |
– |
return (int)(nextLong() >>> (64 - bits)); |
545 |
– |
} |
546 |
– |
|
547 |
– |
/** |
534 |
|
* Returns a pseudorandom {@code double} value between the specified |
535 |
|
* origin (inclusive) and bound (exclusive). |
536 |
|
* |
779 |
|
* @return a stream of pseudorandom {@code double} values, |
780 |
|
* each with the given origin (inclusive) and bound (exclusive) |
781 |
|
* @throws IllegalArgumentException if {@code streamSize} is |
782 |
< |
* less than zero |
797 |
< |
* @throws IllegalArgumentException if {@code randomNumberOrigin} |
782 |
> |
* less than zero, or {@code randomNumberOrigin} |
783 |
|
* is greater than or equal to {@code randomNumberBound} |
784 |
|
*/ |
785 |
|
public DoubleStream doubles(long streamSize, double randomNumberOrigin, |