commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject [1/2] commons-statistics git commit: Default methods.
Date Thu, 25 Jan 2018 14:41:18 GMT
Repository: commons-statistics
Updated Branches:
  refs/heads/master 3a44cfd80 -> a27fba727


Default methods.


Project: http://git-wip-us.apache.org/repos/asf/commons-statistics/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-statistics/commit/02146b04
Tree: http://git-wip-us.apache.org/repos/asf/commons-statistics/tree/02146b04
Diff: http://git-wip-us.apache.org/repos/asf/commons-statistics/diff/02146b04

Branch: refs/heads/master
Commit: 02146b04ae201d955bf29a68f1cea59bbf7e14c3
Parents: 3a44cfd
Author: Gilles Sadowski <gilles@harfang.homelinux.org>
Authored: Thu Jan 25 15:39:49 2018 +0100
Committer: Gilles Sadowski <gilles@harfang.homelinux.org>
Committed: Thu Jan 25 15:39:49 2018 +0100

----------------------------------------------------------------------
 .../AbstractContinuousDistribution.java         | 20 --------------------
 .../distribution/ContinuousDistribution.java    |  8 ++++++--
 2 files changed, 6 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-statistics/blob/02146b04/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/AbstractContinuousDistribution.java
----------------------------------------------------------------------
diff --git a/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/AbstractContinuousDistribution.java
b/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/AbstractContinuousDistribution.java
index 37f66ec..5350120 100644
--- a/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/AbstractContinuousDistribution.java
+++ b/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/AbstractContinuousDistribution.java
@@ -180,26 +180,6 @@ abstract class AbstractContinuousDistribution
     }
 
     /**
-     * {@inheritDoc}
-     *
-     * @return zero.
-     */
-    @Override
-    public double probability(double x) {
-        return 0;
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * The default implementation computes the logarithm of {@code density(x)}.
-     */
-    @Override
-    public double logDensity(double x) {
-        return Math.log(density(x));
-    }
-
-    /**
      * Utility function for allocating an array and filling it with {@code n}
      * samples generated by the given {@code sampler}.
      *

http://git-wip-us.apache.org/repos/asf/commons-statistics/blob/02146b04/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/ContinuousDistribution.java
----------------------------------------------------------------------
diff --git a/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/ContinuousDistribution.java
b/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/ContinuousDistribution.java
index 6d3cb3e..74611df 100644
--- a/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/ContinuousDistribution.java
+++ b/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/ContinuousDistribution.java
@@ -31,7 +31,9 @@ public interface ContinuousDistribution {
      * @param x Point at which the PMF is evaluated.
      * @return the value of the probability mass function at point {@code x}.
      */
-    double probability(double x);
+    default double probability(double x) {
+        return 0;
+    }
 
     /**
      * For a random variable {@code X} whose values are distributed according
@@ -68,7 +70,9 @@ public interface ContinuousDistribution {
      * @return the logarithm of the value of the probability density function
      * at {@code x}.
      */
-    double logDensity(double x);
+    default double logDensity(double x) {
+        return Math.log(density(x));
+    }
 
     /**
      * For a random variable {@code X} whose values are distributed according


Mime
View raw message