You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2021/10/27 11:47:13 UTC
[commons-statistics] branch master updated (e65195a -> 2d12bb2)
This is an automated email from the ASF dual-hosted git repository.
aherbert pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-statistics.git.
from e65195a Remove obsolete test tolerance property
new b774694 Sonar fix: Create double from sum of integers for power function
new cb27bbe Remove spurious @Test annotation
new c174f7d Sonar fix: rename var for temporary variance variables
new 2d12bb2 Sonar fix: Comment disabled test
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../commons/statistics/distribution/TDistribution.java | 6 +++---
.../statistics/distribution/TruncatedNormalDistribution.java | 12 ++++++------
.../commons/statistics/distribution/ZipfDistribution.java | 4 ++--
.../statistics/distribution/ExtendedPrecisionTest.java | 1 -
.../statistics/distribution/GammaDistributionTest.java | 2 +-
5 files changed, 12 insertions(+), 13 deletions(-)
[commons-statistics] 03/04: Sonar fix: rename var for temporary
variance variables
Posted by ah...@apache.org.
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-statistics.git
commit c174f7d350c56c2fd4aa17c2e577f2fd3f326ef3
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Wed Oct 27 12:43:05 2021 +0100
Sonar fix: rename var for temporary variance variables
var is a restricted identifier.
---
.../commons/statistics/distribution/TDistribution.java | 6 +++---
.../statistics/distribution/TruncatedNormalDistribution.java | 12 ++++++------
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/TDistribution.java b/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/TDistribution.java
index 11dce96..6985dca 100644
--- a/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/TDistribution.java
+++ b/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/TDistribution.java
@@ -248,11 +248,11 @@ public abstract class TDistribution extends AbstractContinuousDistribution {
}
// If the variance converges to 1 use a NormalDistribution.
// Occurs at 2^55 = 3.60e16
- final double var = StudentsTDistribution.computeVariance(degreesOfFreedom);
- if (var == 1) {
+ final double variance = StudentsTDistribution.computeVariance(degreesOfFreedom);
+ if (variance == 1) {
return new NormalTDistribution(degreesOfFreedom);
}
- return new StudentsTDistribution(degreesOfFreedom, var);
+ return new StudentsTDistribution(degreesOfFreedom, variance);
}
/**
diff --git a/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/TruncatedNormalDistribution.java b/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/TruncatedNormalDistribution.java
index 97a781b..a921b81 100644
--- a/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/TruncatedNormalDistribution.java
+++ b/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/TruncatedNormalDistribution.java
@@ -80,25 +80,25 @@ public final class TruncatedNormalDistribution extends AbstractContinuousDistrib
// lower or upper may be infinite or the density is zero.
double mu;
- double var;
+ double v;
if (lower == Double.NEGATIVE_INFINITY || pdfAlpha == 0) {
if (upper == Double.POSITIVE_INFINITY || pdfBeta == 0) {
// No truncation
mu = mean;
- var = sd * sd;
+ v = sd * sd;
} else {
// One sided truncation (of upper tail)
final double betaRatio = pdfBeta / cdfDelta;
mu = mean - sd * betaRatio;
- var = sd * sd * (1 - beta * betaRatio - betaRatio * betaRatio);
+ v = sd * sd * (1 - beta * betaRatio - betaRatio * betaRatio);
}
} else {
if (upper == Double.POSITIVE_INFINITY || pdfBeta == 0) {
// One sided truncation (of lower tail)
final double alphaRatio = pdfAlpha / cdfDelta;
mu = mean + sd * alphaRatio;
- var = sd * sd * (1 + alpha * alphaRatio - alphaRatio * alphaRatio);
+ v = sd * sd * (1 + alpha * alphaRatio - alphaRatio * alphaRatio);
} else {
// Two-sided truncation
// Note:
@@ -110,14 +110,14 @@ public final class TruncatedNormalDistribution extends AbstractContinuousDistrib
final double pdfCdfDelta = (pdfAlpha - pdfBeta) / z;
final double alphaBetaDelta = (alpha * pdfAlpha - beta * pdfBeta) / z;
mu = mean + pdfCdfDelta * sd;
- var = sd * sd * (1 + alphaBetaDelta - pdfCdfDelta * pdfCdfDelta);
+ v = sd * sd * (1 + alphaBetaDelta - pdfCdfDelta * pdfCdfDelta);
}
}
// The mean should be clipped to the range [lower, upper].
// The variance should be less than the variance of the parent normal distribution.
this.mean = clipToRange(mu);
- variance = Math.min(var, sd * sd);
+ variance = Math.min(v, sd * sd);
}
/**
[commons-statistics] 04/04: Sonar fix: Comment disabled test
Posted by ah...@apache.org.
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-statistics.git
commit 2d12bb23bef8cadfdb400350584cd861ee0de3f5
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Wed Oct 27 12:44:51 2021 +0100
Sonar fix: Comment disabled test
---
.../apache/commons/statistics/distribution/GammaDistributionTest.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/GammaDistributionTest.java b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/GammaDistributionTest.java
index 6f70f02..28b0d05 100644
--- a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/GammaDistributionTest.java
+++ b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/GammaDistributionTest.java
@@ -134,7 +134,7 @@ class GammaDistributionTest extends BaseContinuousDistributionTest {
* be very large.
*/
@Test
- @Disabled
+ @Disabled("Implementation fails for small x")
void testShapeBelow1() {
// R2.5: print(dgamma(x, shape=0.05, rate=1), digits=20)
final double[] x = new double[]{1e-100, 1e-10, 1e-5, 0.1};
[commons-statistics] 01/04: Sonar fix: Create double from sum of
integers for power function
Posted by ah...@apache.org.
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-statistics.git
commit b774694323f271c0deaf10e9848edb575fa8250c
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Wed Oct 27 12:31:30 2021 +0100
Sonar fix: Create double from sum of integers for power function
---
.../org/apache/commons/statistics/distribution/ZipfDistribution.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/ZipfDistribution.java b/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/ZipfDistribution.java
index addc503..08d1c3a 100644
--- a/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/ZipfDistribution.java
+++ b/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/ZipfDistribution.java
@@ -143,10 +143,10 @@ public final class ZipfDistribution extends AbstractDiscreteDistribution {
// See http://www.math.wm.edu/~leemis/chart/UDR/PDFs/Zipf.pdf
// S(x) = P(X > x) = ((x+1)^a Hn,a - (x+1)^a Hx+1,a + 1) / ((x+1)^a Hn,a)
// where a = exponent and Hx,a is the generalized harmonic for x with exponent a.
- final double z = Math.pow(x + 1, exponent);
+ final double z = Math.pow(x + 1.0, exponent);
// Compute generalizedHarmonic(x, exponent) and generalizedHarmonic(x+1, exponent)
final double hx = generalizedHarmonic(x, exponent);
- final double hx1 = hx + Math.pow(x + 1, -exponent);
+ final double hx1 = hx + Math.pow(x + 1.0, -exponent);
// Compute the survival function
final double p = (z * (nthHarmonic - hx1) + 1) / (z * nthHarmonic);
// May overflow for large exponent so validate the probability.
[commons-statistics] 02/04: Remove spurious @Test annotation
Posted by ah...@apache.org.
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-statistics.git
commit cb27bbefed621a9109cea37d40b32c1f493b90a7
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Wed Oct 27 12:32:20 2021 +0100
Remove spurious @Test annotation
---
.../apache/commons/statistics/distribution/ExtendedPrecisionTest.java | 1 -
1 file changed, 1 deletion(-)
diff --git a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/ExtendedPrecisionTest.java b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/ExtendedPrecisionTest.java
index a864f42..3c6398a 100644
--- a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/ExtendedPrecisionTest.java
+++ b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/ExtendedPrecisionTest.java
@@ -149,7 +149,6 @@ class ExtendedPrecisionTest {
assertSqrt2xxStandardPrecision(RMS2, 1.3, 0.6);
}
- @Test
private static void assertSqrt2xxStandardPrecision(RMS rms, double maxError, double rmsError) {
Assertions.assertTrue(rms.getMax() < maxError, () -> "max error: " + rms.getMax());
Assertions.assertTrue(rms.getRMS() < rmsError, () -> "rms error: " + rms.getRMS());