commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From celes...@apache.org
Subject svn commit: r1210359 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/
Date Mon, 05 Dec 2011 08:15:38 GMT
Author: celestin
Date: Mon Dec  5 08:15:38 2011
New Revision: 1210359

URL: http://svn.apache.org/viewvc?rev=1210359&view=rev
Log:
- Corrected expressions for mean and variance in distribution.PascalDistribution (MATH-715).
- Made javadoc more explicit
- Restored SVN properties to various files in package distribution.

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractRealDistribution.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BetaDistribution.java
  (props changed)
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BinomialDistribution.java
  (props changed)
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/CauchyDistribution.java
  (props changed)
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistribution.java
  (props changed)
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ExponentialDistribution.java
  (props changed)
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/FDistribution.java
  (props changed)
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/GammaDistribution.java
  (props changed)
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/HypergeometricDistribution.java
  (props changed)
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/KolmogorovSmirnovDistribution.java
  (props changed)
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/NormalDistribution.java
  (props changed)
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PascalDistribution.java
  (contents, props changed)
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PoissonDistribution.java
  (props changed)
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/SaddlePointExpansion.java
  (props changed)
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/TDistribution.java
  (props changed)
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/WeibullDistribution.java
  (props changed)
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ZipfDistribution.java
  (props changed)

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractRealDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractRealDistribution.java?rev=1210359&r1=1210358&r2=1210359&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractRealDistribution.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractRealDistribution.java
Mon Dec  5 08:15:38 2011
@@ -43,12 +43,12 @@ implements RealDistribution, Serializabl
     /** Serializable version identifier */
     private static final long serialVersionUID = -38038050983108802L;
 
-    /** Solver absolute accuracy for inverse cumulative computation */
-    private double solverAbsoluteAccuracy = SOLVER_DEFAULT_ABSOLUTE_ACCURACY;
-
     /** RandomData instance used to generate samples from the distribution. */
     protected final RandomDataImpl randomData = new RandomDataImpl();
 
+    /** Solver absolute accuracy for inverse cumulative computation */
+    private double solverAbsoluteAccuracy = SOLVER_DEFAULT_ABSOLUTE_ACCURACY;
+
     /** Default constructor. */
     protected AbstractRealDistribution() { }
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PascalDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PascalDistribution.java?rev=1210359&r1=1210358&r2=1210359&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PascalDistribution.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PascalDistribution.java
Mon Dec  5 08:15:38 2011
@@ -31,10 +31,25 @@ import org.apache.commons.math.util.Fast
  * </p>
  * <p>
  * There are various ways to express the probability mass and distribution
- * functions for the Pascal distribution.  The convention employed by the
- * library is to express these functions in terms of the number of failures in
- * a Bernoulli experiment
- * (see <a href="http://en.wikipedia.org/wiki/Negative_binomial_distribution#Waiting_time_in_a_Bernoulli_process">Waiting
Time in a Bernoulli Process</a>).
+ * functions for the Pascal distribution. The present implementation represents
+ * the distribution of the number of failures before {@code r} successes occur.
+ * This is the convention adopted in e.g.
+ * <a href="http://mathworld.wolfram.com/NegativeBinomialDistribution.html">MathWorld</a>,
+ * but <em>not</em> in
+ * <a href="http://en.wikipedia.org/wiki/Negative_binomial_distribution">Wikipedia</a>.
+ * </p>
+ * <p>
+ * For a random variable {@code X} whose values are distributed according to this
+ * distribution, the probability mass function is given by<br/>
+ * {@code P(X = k) = C(k + r - 1, r - 1) * p^r * (1 - p)^k,}<br/>
+ * where {@code r} is the number of successes, {@code p} is the probability of
+ * success, and {@code X} is the total number of failures. {@code C(n, k)} is
+ * the binomial coefficient ({@code n} choose {@code k}). The mean and variance
+ * of {@code X} are<br/>
+ * {@code E(X) = (1 - p) * r / p, var(X) = (1 - p) * r / p^2.}<br/>
+ * Finally, the cumulative distribution function is given by<br/>
+ * {@code P(X <= k) = I(p, r, k + 1)},
+ * where I is the regularized incomplete Beta function.
  * </p>
  *
  * @see <a href="http://en.wikipedia.org/wiki/Negative_binomial_distribution">
@@ -159,25 +174,24 @@ public class PascalDistribution extends 
      * {@inheritDoc}
      *
      * For number of successes {@code r} and probability of success {@code p},
-     * the mean is {@code (r * p) / (1 - p)}.
+     * the mean is {@code r * (1 - p) / p}.
      */
     public double getNumericalMean() {
         final double p = getProbabilityOfSuccess();
         final double r = getNumberOfSuccesses();
-        return (r * p) / (1 - p);
+        return (r * (1 - p)) / p;
     }
 
     /**
      * {@inheritDoc}
      *
      * For number of successes {@code r} and probability of success {@code p},
-     * the variance is {@code (r * p) / (1 - p)^2}.
+     * the variance is {@code r * (1 - p) / p^2}.
      */
     public double getNumericalVariance() {
         final double p = getProbabilityOfSuccess();
         final double r = getNumberOfSuccesses();
-        final double pInv = 1 - p;
-        return (r * p) / (pInv * pInv);
+        return r * (1 - p) / (p * p);
     }
 
     /**

Propchange: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/SaddlePointExpansion.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



Mime
View raw message