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
The following commit(s) were added to refs/heads/master by this push: new a2fd490 * Replace Anonymous type with lambda. * inline variable * remove unnecessary return. new 45e5689 Merge pull request #29 from arturobernalg/feature/improvements a2fd490 is described below commit a2fd490b60bde008c904dd5d4df8c1b34180256a Author: Arturo Bernal <arturobern...@gmail.com> AuthorDate: Sat Aug 7 09:29:18 2021 +0200 * Replace Anonymous type with lambda. * inline variable * remove unnecessary return. --- .../statistics/distribution/ZipfDistribution.java | 3 +-- .../distribution/AbstractContinuousDistributionTest.java | 16 ++-------------- .../distribution/ContinuousDistributionAbstractTest.java | 7 +------ .../statistics/distribution/TDistributionTest.java | 1 - 4 files changed, 4 insertions(+), 23 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 95c955e..60e0261 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 @@ -134,9 +134,8 @@ public class ZipfDistribution extends AbstractDiscreteDistribution { final double s = getExponent(); final double Hs1 = generalizedHarmonic(N, s - 1); - final double Hs = nthHarmonic; - return Hs1 / Hs; + return Hs1 / nthHarmonic; } /** diff --git a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/AbstractContinuousDistributionTest.java b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/AbstractContinuousDistributionTest.java index 059a0bb..92e5a9a 100644 --- a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/AbstractContinuousDistributionTest.java +++ b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/AbstractContinuousDistributionTest.java @@ -147,13 +147,7 @@ class AbstractContinuousDistributionTest { @Override public double getMean() { - final UnivariateFunction f = new UnivariateFunction() { - - @Override - public double value(final double x) { - return x * density(x); - } - }; + final UnivariateFunction f = x -> x * density(x); final UnivariateIntegrator integrator = new RombergIntegrator(); return integrator.integrate(Integer.MAX_VALUE, f, x0, x4); } @@ -161,13 +155,7 @@ class AbstractContinuousDistributionTest { @Override public double getVariance() { final double meanX = getMean(); - final UnivariateFunction f = new UnivariateFunction() { - - @Override - public double value(final double x) { - return x * x * density(x); - } - }; + final UnivariateFunction f = x -> x * x * density(x); final UnivariateIntegrator integrator = new RombergIntegrator(); final double meanX2 = integrator.integrate(Integer.MAX_VALUE, f, x0, x4); diff --git a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/ContinuousDistributionAbstractTest.java b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/ContinuousDistributionAbstractTest.java index 59e13cb..2ccd017 100644 --- a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/ContinuousDistributionAbstractTest.java +++ b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/ContinuousDistributionAbstractTest.java @@ -494,12 +494,7 @@ abstract class ContinuousDistributionAbstractTest { final double tol = 1e-9; final BaseAbstractUnivariateIntegrator integrator = new IterativeLegendreGaussIntegrator(5, 1e-12, 1e-10); - final UnivariateFunction d = new UnivariateFunction() { - @Override - public double value(double x) { - return distribution.density(x); - } - }; + final UnivariateFunction d = distribution::density; final ArrayList<Double> integrationTestPoints = new ArrayList<>(); for (int i = 0; i < cumulativeTestPoints.length; i++) { if (Double.isNaN(cumulativeTestValues[i]) || diff --git a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/TDistributionTest.java b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/TDistributionTest.java index 2d0b457..be1635d 100644 --- a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/TDistributionTest.java +++ b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/TDistributionTest.java @@ -179,7 +179,6 @@ class TDistributionTest extends ContinuousDistributionAbstractTest { TestUtils.assertEquals(prob, makeNistResults(args10, 10), 1.0e-4); TestUtils.assertEquals(prob, makeNistResults(args30, 30), 1.0e-4); TestUtils.assertEquals(prob, makeNistResults(args100, 100), 1.0e-4); - return; } // See https://issues.apache.org/jira/browse/STATISTICS-25