This is an automated email from the ASF dual-hosted git repository. aherbert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-rng.git
commit ca5576eb1eee82635027faf9d92d5f0a73d96a68 Author: Alex Herbert <[email protected]> AuthorDate: Wed Nov 22 15:25:10 2023 +0000 Precompute constant --- .../org/apache/commons/rng/sampling/distribution/InternalGamma.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InternalGamma.java b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InternalGamma.java index 5b53cca0..99e2c160 100644 --- a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InternalGamma.java +++ b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InternalGamma.java @@ -52,8 +52,8 @@ final class InternalGamma { // Class is package-private on purpose; do not make .36899182659531622704e-5, }; - /** Avoid repeated computation of log of 2 PI in logGamma. */ - private static final double HALF_LOG_2_PI = 0.5 * Math.log(2.0 * Math.PI); + /** Avoid repeated computation of log(2*PI) / 2 in logGamma. */ + private static final double HALF_LOG_2_PI = 0.91893853320467274178032973640562; /** * Class contains only static methods. @@ -90,7 +90,7 @@ final class InternalGamma { // Class is package-private on purpose; do not make final double sum = lanczos(x); final double tmp = x + LANCZOS_G + 0.5; - return (x + 0.5) * Math.log(tmp) - tmp + HALF_LOG_2_PI + Math.log(sum / x); + return (x + 0.5) * Math.log(tmp) - tmp + HALF_LOG_2_PI + Math.log(sum / x); } /**
