Repository: commons-math
Updated Branches:
  refs/heads/master ece7c6fc6 -> 0d3545e5f


[MATH-1039] Added logDensity and logProbability methods to RealDistribution and 
IntegerDistribution interfaces.


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/0d3545e5
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/0d3545e5
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/0d3545e5

Branch: refs/heads/master
Commit: 0d3545e5f68d024cd4a05724a15746d8dad986d2
Parents: ece7c6f
Author: Thomas Neidhart <thomas.neidh...@gmail.com>
Authored: Tue Feb 24 23:30:55 2015 +0100
Committer: Thomas Neidhart <thomas.neidh...@gmail.com>
Committed: Tue Feb 24 23:30:55 2015 +0100

----------------------------------------------------------------------
 src/changes/changes.xml                           |  5 +++++
 .../distribution/AbstractIntegerDistribution.java | 14 ++------------
 .../distribution/AbstractRealDistribution.java    | 15 +++------------
 .../math4/distribution/IntegerDistribution.java   | 18 +++++++++++++++++-
 .../math4/distribution/RealDistribution.java      | 17 +++++++++++++++++
 5 files changed, 44 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/0d3545e5/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 273d949..af87c56 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -54,6 +54,11 @@ If the output is not quite correct, check for invisible 
trailing spaces!
     </release>
 
     <release version="4.0" date="XXXX-XX-XX" description="">
+      <action dev="tn" type="add" issue="MATH-1039" due-to="Aleksei Dievskii">
+        Added logDensity(double) to RealDistribution and logProbability(int)
+        to IntegerDistribution interface. The implementations have already been
+        updated in release 3.3. 
+      </action>
       <action dev="tn" type="update" issue="MATH-1155">
         WELL type pseudo-random number generators have been refactored:
         the cached indirection index tables per instance are now stored

http://git-wip-us.apache.org/repos/asf/commons-math/blob/0d3545e5/src/main/java/org/apache/commons/math4/distribution/AbstractIntegerDistribution.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/commons/math4/distribution/AbstractIntegerDistribution.java
 
b/src/main/java/org/apache/commons/math4/distribution/AbstractIntegerDistribution.java
index adaed88..1b0f263 100644
--- 
a/src/main/java/org/apache/commons/math4/distribution/AbstractIntegerDistribution.java
+++ 
b/src/main/java/org/apache/commons/math4/distribution/AbstractIntegerDistribution.java
@@ -212,19 +212,9 @@ public abstract class AbstractIntegerDistribution 
implements IntegerDistribution
     }
 
     /**
-     * For a random variable {@code X} whose values are distributed according 
to
-     * this distribution, this method returns {@code log(P(X = x))}, where
-     * {@code log} is the natural logarithm. In other words, this method
-     * represents the logarithm of the probability mass function (PMF) for the
-     * distribution. Note that due to the floating point precision and
-     * under/overflow issues, this method will for some distributions be more
-     * precise and faster than computing the logarithm of
-     * {@link #probability(int)}.
+     * {@inheritDoc}
      * <p>
-     * The default implementation simply computes the logarithm of {@code 
probability(x)}.</p>
-     *
-     * @param x the point at which the PMF is evaluated
-     * @return the logarithm of the value of the probability mass function at 
{@code x}
+     * The default implementation simply computes the logarithm of {@code 
probability(x)}.
      */
     public double logProbability(int x) {
         return FastMath.log(probability(x));

http://git-wip-us.apache.org/repos/asf/commons-math/blob/0d3545e5/src/main/java/org/apache/commons/math4/distribution/AbstractRealDistribution.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/commons/math4/distribution/AbstractRealDistribution.java
 
b/src/main/java/org/apache/commons/math4/distribution/AbstractRealDistribution.java
index 297da1a..9918df2 100644
--- 
a/src/main/java/org/apache/commons/math4/distribution/AbstractRealDistribution.java
+++ 
b/src/main/java/org/apache/commons/math4/distribution/AbstractRealDistribution.java
@@ -268,18 +268,9 @@ implements RealDistribution, Serializable {
     }
 
     /**
-     * Returns the natural logarithm of the probability density function (PDF) 
of this distribution
-     * evaluated at the specified point {@code x}. In general, the PDF is the 
derivative of the
-     * {@link #cumulativeProbability(double) CDF}. If the derivative does not 
exist at {@code x},
-     * then an appropriate replacement should be returned, e.g. {@code 
Double.POSITIVE_INFINITY},
-     * {@code Double.NaN}, or the limit inferior or limit superior of the 
difference quotient. Note
-     * that due to the floating point precision and under/overflow issues, 
this method will for some
-     * distributions be more precise and faster than computing the logarithm of
-     * {@link #density(double)}. The default implementation simply computes 
the logarithm of
-     * {@code density(x)}.
-     *
-     * @param x the point at which the PDF is evaluated
-     * @return the logarithm of the value of the probability density function 
at point {@code x}
+     * {@inheritDoc}
+     * <p>
+     * The default implementation simply computes the logarithm of {@code 
density(x)}.
      */
     public double logDensity(double x) {
         return FastMath.log(density(x));

http://git-wip-us.apache.org/repos/asf/commons-math/blob/0d3545e5/src/main/java/org/apache/commons/math4/distribution/IntegerDistribution.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/commons/math4/distribution/IntegerDistribution.java 
b/src/main/java/org/apache/commons/math4/distribution/IntegerDistribution.java
index a905b3b..f1299c6 100644
--- 
a/src/main/java/org/apache/commons/math4/distribution/IntegerDistribution.java
+++ 
b/src/main/java/org/apache/commons/math4/distribution/IntegerDistribution.java
@@ -21,9 +21,25 @@ import 
org.apache.commons.math4.exception.OutOfRangeException;
 
 /**
  * Interface for distributions on the integers.
- *
  */
 public interface IntegerDistribution {
+    
+    /**
+     * For a random variable {@code X} whose values are distributed according 
to
+     * this distribution, this method returns {@code log(P(X = x))}, where
+     * {@code log} is the natural logarithm. In other words, this method
+     * represents the logarithm of the probability mass function (PMF) for the
+     * distribution. Note that due to the floating point precision and
+     * under/overflow issues, this method will for some distributions be more
+     * precise and faster than computing the logarithm of
+     * {@link #probability(int)}.
+     *
+     * @param x the point at which the PMF is evaluated
+     * @return the logarithm of the value of the probability mass function at 
{@code x}
+     * @since 4.0
+     */
+    double logProbability(int x);
+    
     /**
      * For a random variable {@code X} whose values are distributed according
      * to this distribution, this method returns {@code P(X = x)}. In other

http://git-wip-us.apache.org/repos/asf/commons-math/blob/0d3545e5/src/main/java/org/apache/commons/math4/distribution/RealDistribution.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/commons/math4/distribution/RealDistribution.java 
b/src/main/java/org/apache/commons/math4/distribution/RealDistribution.java
index d4ed518..728e2e3 100644
--- a/src/main/java/org/apache/commons/math4/distribution/RealDistribution.java
+++ b/src/main/java/org/apache/commons/math4/distribution/RealDistribution.java
@@ -51,6 +51,23 @@ public interface RealDistribution {
     double density(double x);
 
     /**
+     * Returns the natural logarithm of the probability density function
+     * (PDF) of this distribution evaluated at the specified point {@code x}.
+     * In general, the PDF is the derivative of the {@link 
#cumulativeProbability(double) CDF}.
+     * If the derivative does not exist at {@code x}, then an appropriate 
replacement
+     * should be returned, e.g. {@code Double.POSITIVE_INFINITY}, {@code 
Double.NaN},
+     * or the limit inferior or limit superior of the difference quotient. 
Note that
+     * due to the floating point precision and under/overflow issues, this 
method will
+     * for some distributions be more precise and faster than computing the 
logarithm of
+     * {@link #density(double)}.
+     *
+     * @param x the point at which the PDF is evaluated
+     * @return the logarithm of the value of the probability density function 
at point {@code x}
+     * @since 4.0
+     */
+    double logDensity(double x);
+
+    /**
      * For a random variable {@code X} whose values are distributed according
      * to this distribution, this method returns {@code P(X <= x)}. In other
      * words, this method represents the (cumulative) distribution function

Reply via email to