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 1578a79ac74930545ef4b8e1865ab774746f298a Author: Alex Herbert <aherb...@apache.org> AuthorDate: Wed Jul 3 15:12:15 2024 +0100 PMD fix: use final --- .../commons/rng/sampling/distribution/BoxMullerGaussianSampler.java | 2 +- .../rng/sampling/distribution/BoxMullerNormalizedGaussianSampler.java | 2 +- .../org/apache/commons/rng/sampling/distribution/InternalUtils.java | 2 +- .../apache/commons/rng/sampling/distribution/PoissonSamplerCache.java | 4 ++-- .../org/apache/commons/rng/sampling/distribution/StableSampler.java | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/BoxMullerGaussianSampler.java b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/BoxMullerGaussianSampler.java index 1d3d6b9b..008e4356 100644 --- a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/BoxMullerGaussianSampler.java +++ b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/BoxMullerGaussianSampler.java @@ -76,7 +76,7 @@ public class BoxMullerGaussianSampler /** {@inheritDoc} */ @Override public double sample() { - double random; + final double random; if (Double.isNaN(nextGaussian)) { // Generate a pair of Gaussian numbers. diff --git a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/BoxMullerNormalizedGaussianSampler.java b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/BoxMullerNormalizedGaussianSampler.java index 8859c1ce..6553c790 100644 --- a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/BoxMullerNormalizedGaussianSampler.java +++ b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/BoxMullerNormalizedGaussianSampler.java @@ -49,7 +49,7 @@ public class BoxMullerNormalizedGaussianSampler /** {@inheritDoc} */ @Override public double sample() { - double random; + final double random; if (Double.isNaN(nextGaussian)) { // Generate a pair of Gaussian numbers. diff --git a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InternalUtils.java b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InternalUtils.java index 14e9d3df..24b221ed 100644 --- a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InternalUtils.java +++ b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InternalUtils.java @@ -290,7 +290,7 @@ final class InternalUtils { double[] cache) { logFactorials = new double[numValues]; - int endCopy; + final int endCopy; if (cache != null && cache.length > BEGIN_LOG_FACTORIALS) { // Copy available values. endCopy = Math.min(cache.length, numValues); diff --git a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/PoissonSamplerCache.java b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/PoissonSamplerCache.java index e5191106..8c2ae232 100644 --- a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/PoissonSamplerCache.java +++ b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/PoissonSamplerCache.java @@ -365,8 +365,8 @@ public class PoissonSamplerCache { new LargeMeanPoissonSamplerState[withMaxN - withMinN + 1]; // Preserve values from the current array to the next - int currentIndex; - int nextIndex; + final int currentIndex; + final int nextIndex; if (this.minN <= withMinN) { // The current array starts before the new array currentIndex = withMinN - this.minN; diff --git a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/StableSampler.java b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/StableSampler.java index 276a72c7..0e45fbfa 100644 --- a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/StableSampler.java +++ b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/StableSampler.java @@ -757,7 +757,7 @@ public abstract class StableSampler implements SharedStateContinuousSampler { final double eps = 1 - alpha; final double meps1 = 1 - eps; // Compute RSTAB prefactor - double tau; + final double tau; // tau is symmetric around alpha=1 // tau -> beta / pi/2 as alpha -> 1