mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 12:09:14 +00:00
8372134: ThreadLocalRandom no longer overrides nextGaussian
Reviewed-by: alanb, rgiulietti, vklang
This commit is contained in:
parent
8a0672c819
commit
f1d90b8b25
@ -128,11 +128,6 @@ public final class ThreadLocalRandom extends Random {
|
||||
* Implementations of non-core methods are mostly the same as in
|
||||
* SplittableRandom, that were in part derived from a previous
|
||||
* version of this class.
|
||||
*
|
||||
* This implementation of ThreadLocalRandom overrides the
|
||||
* definition of the nextGaussian() method in the class Random,
|
||||
* and instead uses the ziggurat-based algorithm that is the
|
||||
* default for the RandomGenerator interface.
|
||||
*/
|
||||
|
||||
private static int mix32(long z) {
|
||||
@ -499,6 +494,23 @@ public final class ThreadLocalRandom extends Random {
|
||||
return super.nextLong(origin, bound);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@code double} value pseudorandomly chosen from a Gaussian
|
||||
* (normal) distribution whose mean is 0 and whose standard deviation is 1.
|
||||
*
|
||||
* @return a {@code double} value pseudorandomly chosen from a
|
||||
* Gaussian distribution
|
||||
*
|
||||
* @implNote This implementation invokes the default implementation of
|
||||
* {@link java.util.random.RandomGenerator#nextGaussian()},
|
||||
* and so it uses McFarland's fast modified ziggurat algorithm
|
||||
* rather than the polar method described in the superclass.
|
||||
*/
|
||||
@Override
|
||||
public double nextGaussian() {
|
||||
return RandomSupport.computeNextGaussian(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@ -510,7 +522,6 @@ public final class ThreadLocalRandom extends Random {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @throws IllegalArgumentException {@inheritDoc}
|
||||
* @implNote {@inheritDoc}
|
||||
*
|
||||
* @since 17
|
||||
*/
|
||||
@ -522,7 +533,6 @@ public final class ThreadLocalRandom extends Random {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @throws IllegalArgumentException {@inheritDoc}
|
||||
* @implNote {@inheritDoc}
|
||||
*
|
||||
* @since 17
|
||||
*/
|
||||
@ -542,7 +552,6 @@ public final class ThreadLocalRandom extends Random {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @throws IllegalArgumentException {@inheritDoc}
|
||||
* @implNote {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public double nextDouble(double bound) {
|
||||
@ -552,7 +561,6 @@ public final class ThreadLocalRandom extends Random {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @throws IllegalArgumentException {@inheritDoc}
|
||||
* @implNote {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public double nextDouble(double origin, double bound) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -917,7 +917,6 @@ public interface RandomGenerator {
|
||||
* a discrete distribution also plays a role.
|
||||
*/
|
||||
default double nextGaussian() {
|
||||
// See Knuth, TAOCP, Vol. 2, 3rd edition, Section 3.4.1 Algorithm C.
|
||||
return RandomSupport.computeNextGaussian(this);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user