commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From celes...@apache.org
Subject svn commit: r1206421 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math/distribution/ main/java/org/apache/commons/math/random/ main/java/org/apache/commons/math/stat/inference/ test/java/org/apache/commons/math/distribution/ test/j...
Date Sat, 26 Nov 2011 10:17:52 GMT
Author: celestin
Date: Sat Nov 26 10:17:49 2011
New Revision: 1206421

URL: http://svn.apache.org/viewvc?rev=1206421&view=rev
Log:
Merged NormalDistribution and NormalDistributionImpl (MATH-711).
Merged PascalDistribution and PascalDistributionImpl (MATH-711).

Added:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/NormalDistribution.java
      - copied, changed from r1206052, commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/NormalDistributionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PascalDistribution.java
      - copied, changed from r1206052, commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PascalDistributionImpl.java
Removed:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/NormalDistributionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PascalDistributionImpl.java
Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PoissonDistributionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomDataImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/MannWhitneyUTestImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/WilcoxonSignedRankTestImpl.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/CauchyDistributionTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/NormalDistributionTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/PascalDistributionTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/RandomDataTest.java

Copied: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/NormalDistribution.java
(from r1206052, commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/NormalDistributionImpl.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/NormalDistribution.java?p2=commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/NormalDistribution.java&p1=commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/NormalDistributionImpl.java&r1=1206052&r2=1206421&rev=1206421&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/NormalDistributionImpl.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/NormalDistribution.java
Sat Nov 26 10:17:49 2011
@@ -26,13 +26,14 @@ import org.apache.commons.math.special.E
 import org.apache.commons.math.util.FastMath;
 
 /**
- * Default implementation of
- * {@link org.apache.commons.math.distribution.NormalDistribution}.
+ * Implementation of the normal (gaussian) distribution.
  *
+ * @see <a href="http://en.wikipedia.org/wiki/Normal_distribution">Normal distribution
(Wikipedia)</a>
+ * @see <a href="http://mathworld.wolfram.com/NormalDistribution.html">Normal distribution
(MathWorld)</a>
  * @version $Id$
  */
-public class NormalDistributionImpl extends AbstractContinuousDistribution
-        implements NormalDistribution, Serializable {
+public class NormalDistribution extends AbstractContinuousDistribution
+        implements Serializable {
     /**
      * Default inverse cumulative probability accuracy.
      * @since 2.1
@@ -56,8 +57,10 @@ public class NormalDistributionImpl exte
      *
      * @param mean Mean for this distribution.
      * @param sd Standard deviation for this distribution.
+     * @throws NotStrictlyPositiveException if {@code sd <= 0}.
      */
-    public NormalDistributionImpl(double mean, double sd){
+    public NormalDistribution(double mean, double sd)
+        throws NotStrictlyPositiveException {
         this(mean, sd, DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
     }
 
@@ -71,7 +74,7 @@ public class NormalDistributionImpl exte
      * @throws NotStrictlyPositiveException if {@code sd <= 0}.
      * @since 2.1
      */
-    public NormalDistributionImpl(double mean, double sd, double inverseCumAccuracy) {
+    public NormalDistribution(double mean, double sd, double inverseCumAccuracy) {
         if (sd <= 0) {
             throw new NotStrictlyPositiveException(LocalizedFormats.STANDARD_DEVIATION, sd);
         }
@@ -85,27 +88,29 @@ public class NormalDistributionImpl exte
      * Create a normal distribution with mean equal to zero and standard
      * deviation equal to one.
      */
-    public NormalDistributionImpl(){
+    public NormalDistribution(){
         this(0, 1);
     }
 
     /**
-     * {@inheritDoc}
+     * Access the mean.
+     *
+     * @return the mean for this distribution.
      */
     public double getMean() {
         return mean;
     }
 
     /**
-     * {@inheritDoc}
+     * Access the standard deviation.
+     *
+     * @return the standard deviation for this distribution.
      */
     public double getStandardDeviation() {
         return standardDeviation;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public double density(double x) {
         final double x0 = x - mean;
         final double x1 = x0 / standardDeviation;
@@ -115,8 +120,9 @@ public class NormalDistributionImpl exte
     /**
      * {@inheritDoc}
      *
-     * If {@code x} is more than 40 standard deviations from the mean, 0 or 1 is returned,
-     * as in these cases the actual value is within {@code Double.MIN_VALUE} of 0 or 1.
+     * If {@code x} is more than 40 standard deviations from the mean, 0 or 1
+     * is returned, as in these cases the actual value is within
+     * {@code Double.MIN_VALUE} of 0 or 1.
      */
     public double cumulativeProbability(double x)  {
         final double dev = x - mean;
@@ -126,11 +132,10 @@ public class NormalDistributionImpl exte
         return 0.5 * (1 + Erf.erf(dev / (standardDeviation * SQRT2)));
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     @Override
-    public double cumulativeProbability(double x0, double x1) throws NumberIsTooLargeException
{
+    public double cumulativeProbability(double x0, double x1)
+        throws NumberIsTooLargeException {
         if (x0 > x1) {
             throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT,
                                                 x0, x1, true);
@@ -141,13 +146,7 @@ public class NormalDistributionImpl exte
         return 0.5 * Erf.erf(v0, v1);
     }
 
-    /**
-     * Return the absolute accuracy setting of the solver used to estimate
-     * inverse cumulative probabilities.
-     *
-     * @return the solver absolute accuracy.
-     * @since 2.1
-     */
+    /** {@inheritDoc} */
     @Override
     protected double getSolverAbsoluteAccuracy() {
         return solverAbsoluteAccuracy;
@@ -156,8 +155,8 @@ public class NormalDistributionImpl exte
     /**
      * {@inheritDoc}
      *
-     * It will return {@code Double.NEGATIVE_INFINITY} when {@code p = 0}
-     * and {@code Double.POSITIVE_INFINITY} for {@code p = 1}.
+     * Returns {@code Double.NEGATIVE_INFINITY} when {@code p == 0}
+     * and {@code Double.POSITIVE_INFINITY} for {@code p == 1}.
      */
     @Override
     public double inverseCumulativeProbability(final double p) {
@@ -170,25 +169,13 @@ public class NormalDistributionImpl exte
         return super.inverseCumulativeProbability(p);
     }
 
-    /**
-     * Generate a random value sampled from this distribution.
-     *
-     * @return a random value.
-     * @since 2.2
-     */
+    /** {@inheritDoc} */
     @Override
     public double sample()  {
         return randomData.nextGaussian(mean, standardDeviation);
     }
 
-    /**
-     * Access the domain value lower bound, based on {@code p}, used to
-     * bracket a CDF root.  This method is used by
-     * {@link #inverseCumulativeProbability(double)} to find critical values.
-     *
-     * @param p Desired probability for the critical value.
-     * @return the domain value lower bound, i.e. {@code P(X < 'lower bound') < p}.
-     */
+    /** {@inheritDoc} */
     @Override
     protected double getDomainLowerBound(double p) {
         double ret;
@@ -202,14 +189,7 @@ public class NormalDistributionImpl exte
         return ret;
     }
 
-    /**
-     * Access the domain value upper bound, based on {@code p}, used to
-     * bracket a CDF root.  This method is used by
-     * {@link #inverseCumulativeProbability(double)} to find critical values.
-     *
-     * @param p Desired probability for the critical value.
-     * @return the domain value upper bound, i.e. {@code P(X < 'upper bound') > p}.
-     */
+    /** {@inheritDoc} */
     @Override
     protected double getDomainUpperBound(double p) {
         double ret;
@@ -223,14 +203,7 @@ public class NormalDistributionImpl exte
         return ret;
     }
 
-    /**
-     * Access the initial domain value, based on {@code p}, used to
-     * bracket a CDF root.  This method is used by
-     * {@link #inverseCumulativeProbability(double)} to find critical values.
-     *
-     * @param p Desired probability for the critical value.
-     * @return the initial domain value.
-     */
+    /** {@inheritDoc} */
     @Override
     protected double getInitialDomain(double p) {
         double ret;
@@ -252,7 +225,8 @@ public class NormalDistributionImpl exte
      * The lower bound of the support is always negative infinity
      * no matter the parameters.
      *
-     * @return lower bound of the support (always Double.NEGATIVE_INFINITY)
+     * @return lower bound of the support (always
+     * {@code Double.NEGATIVE_INFINITY})
      */
     @Override
     public double getSupportLowerBound() {
@@ -265,7 +239,8 @@ public class NormalDistributionImpl exte
      * The upper bound of the support is always positive infinity
      * no matter the parameters.
      *
-     * @return upper bound of the support (always Double.POSITIVE_INFINITY)
+     * @return upper bound of the support (always
+     * {@code Double.POSITIVE_INFINITY})
      */
     @Override
     public double getSupportUpperBound() {
@@ -275,9 +250,7 @@ public class NormalDistributionImpl exte
     /**
      * {@inheritDoc}
      *
-     * For mean parameter <code>mu</code>, the mean is <code>mu</code>
-     *
-     * @return {@inheritDoc}
+     * For mean parameter {@code mu}, the mean is {@code mu}.
      */
     @Override
     protected double calculateNumericalMean() {
@@ -287,10 +260,7 @@ public class NormalDistributionImpl exte
     /**
      * {@inheritDoc}
      *
-     * For standard deviation parameter <code>s</code>,
-     * the variance is <code>s^2</code>
-     *
-     * @return {@inheritDoc}
+     * For standard deviation parameter {@code s}, the variance is {@code s^2}.
      */
     @Override
     protected double calculateNumericalVariance() {
@@ -298,17 +268,13 @@ public class NormalDistributionImpl exte
         return s * s;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     @Override
     public boolean isSupportLowerBoundInclusive() {
         return false;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     @Override
     public boolean isSupportUpperBoundInclusive() {
         return false;

Copied: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PascalDistribution.java
(from r1206052, commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PascalDistributionImpl.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PascalDistribution.java?p2=commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PascalDistribution.java&p1=commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PascalDistributionImpl.java&r1=1206052&r2=1206421&rev=1206421&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PascalDistributionImpl.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PascalDistribution.java
Sat Nov 26 10:17:49 2011
@@ -26,12 +26,28 @@ import org.apache.commons.math.util.Arit
 import org.apache.commons.math.util.FastMath;
 
 /**
- * The default implementation of {@link PascalDistribution}.
+ * <p>
+ * Implementation of the Pascal distribution. The Pascal distribution is a
+ * special case of the Negative Binomial distribution where the number of
+ * successes parameter is an integer.
+ * </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>).
+ * </p>
+ *
+ * @see <a href="http://en.wikipedia.org/wiki/Negative_binomial_distribution">
+ * Negative binomial distribution (Wikipedia)</a>
+ * @see <a href="http://mathworld.wolfram.com/NegativeBinomialDistribution.html">
+ * Negative binomial distribution (MathWorld)</a>
  * @version $Id$
- * @since 1.2
+ * @since 1.2 (changed to concrete class in 3.0)
  */
-public class PascalDistributionImpl extends AbstractIntegerDistribution
-    implements PascalDistribution, Serializable {
+public class PascalDistribution extends AbstractIntegerDistribution
+    implements Serializable {
     /** Serializable version identifier. */
     private static final long serialVersionUID = 6751309484392813623L;
     /** The number of successes. */
@@ -45,8 +61,12 @@ public class PascalDistributionImpl exte
      *
      * @param r Number of successes.
      * @param p Probability of success.
+     * @throws NotPositiveException if the number of successes is not positive
+     * @throws OutOfRangeException if the probability of success is not in the
+     * range [0, 1]
      */
-    public PascalDistributionImpl(int r, double p) {
+    public PascalDistribution(int r, double p)
+        throws NotPositiveException, OutOfRangeException {
         if (r < 0) {
             throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SUCCESSES,
                                            r);
@@ -60,51 +80,37 @@ public class PascalDistributionImpl exte
     }
 
     /**
-     * {@inheritDoc}
+     * Access the number of successes for this distribution.
+     *
+     * @return the number of successes.
      */
     public int getNumberOfSuccesses() {
         return numberOfSuccesses;
     }
 
     /**
-     * {@inheritDoc}
+     * Access the probability of success for this distribution.
+     *
+     * @return the probability of success.
      */
     public double getProbabilityOfSuccess() {
         return probabilityOfSuccess;
     }
 
-    /**
-     * Access the domain value lower bound, based on {@code p}, used to
-     * bracket a PDF root.
-     *
-     * @param p Desired probability for the critical value.
-     * @return the domain value lower bound, i.e. {@code P(X < 'lower bound') < p}.
-     */
+    /** {@inheritDoc} */
     @Override
     protected int getDomainLowerBound(double p) {
         return -1;
     }
 
-    /**
-     * Access the domain value upper bound, based on {@code p}, used to
-     * bracket a PDF root.
-     *
-     * @param p Desired probability for the critical value
-     * @return the domain value upper bound, i.e. {@code P(X < 'upper bound') > p}.
-     */
+    /** {@inheritDoc} */
     @Override
     protected int getDomainUpperBound(double p) {
         // use MAX - 1 because MAX causes loop
         return Integer.MAX_VALUE - 1;
     }
 
-    /**
-     * For this distribution, {@code X}, this method returns {@code P(X <= x)}.
-     *
-     * @param x Value at which the PDF is evaluated.
-     * @return PDF for this distribution.
-     * due to convergence or other numerical errors.
-     */
+    /** {@inheritDoc} */
     @Override
     public double cumulativeProbability(int x) {
         double ret;
@@ -117,12 +123,7 @@ public class PascalDistributionImpl exte
         return ret;
     }
 
-    /**
-     * For this distribution, {@code X}, this method returns {@code P(X = x)}.
-     *
-     * @param x Value at which the PMF is evaluated.
-     * @return PMF for this distribution.
-     */
+    /** {@inheritDoc} */
     public double probability(int x) {
         double ret;
         if (x < 0) {
@@ -137,13 +138,10 @@ public class PascalDistributionImpl exte
     }
 
     /**
-     * For this distribution, {@code X}, this method returns the largest
-     * {@code x}, such that {@code P(X <= x) <= p}.
-     * It will return -1 when p = 0 and {@code Integer.MAX_VALUE} when p = 1.
-     *
-     * @param p Desired probability.
-     * @return the largest {@code x} such that {@code P(X <= x) <= p}.
-     * @throws OutOfRangeException if {@code p < 0} or {@code p > 1}.
+     * {@inheritDoc}
+     *
+     * Returns {@code -1} when {@code p == 0} and
+     * {@code Integer.MAX_VALUE} when {@code p == 1}.
      */
     @Override
     public int inverseCumulativeProbability(final double p) {
@@ -176,12 +174,13 @@ public class PascalDistributionImpl exte
     /**
      * {@inheritDoc}
      *
-     * The upper bound of the support is always positive infinity
-     * no matter the parameters. Positive infinity is symbolised
-     * by <code>Integer.MAX_VALUE</code> together with
-     * {@link #isSupportUpperBoundInclusive()} being <code>false</code>
+     * The upper bound of the support is always positive infinity no matter the
+     * parameters. Positive infinity is symbolised by {@code Integer.MAX_VALUE}
+     * together with {@link #isSupportUpperBoundInclusive()} being
+     * {@code false}.
      *
-     * @return upper bound of the support (always <code>Integer.MAX_VALUE</code>
for positive infinity)
+     * @return upper bound of the support (always {@code Integer.MAX_VALUE}
+     * for positive infinity)
      */
     @Override
     public int getSupportUpperBound() {
@@ -191,38 +190,36 @@ public class PascalDistributionImpl exte
     /**
      * {@inheritDoc}
      *
-     * For number of successes <code>r</code> and
-     * probability of success <code>p</code>, the mean is
-     * <code>( r * p ) / ( 1 - p )</code>
-     *
-     * @return {@inheritDoc}
+     * For number of successes {@code r} and probability of success {@code p},
+     * the mean is {@code (r * p) / (1 - p)}.
      */
     @Override
     protected double calculateNumericalMean() {
         final double p = getProbabilityOfSuccess();
         final double r = getNumberOfSuccesses();
-        return ( r * p ) / ( 1 - p );
+        return (r * p) / (1 - p);
     }
 
     /**
      * {@inheritDoc}
      *
-     * For number of successes <code>r</code> and
-     * probability of success <code>p</code>, the mean is
-     * <code>( r * p ) / ( 1 - p )^2</code>
-     *
-     * @return {@inheritDoc}
+     * For number of successes {@code r} and probability of success {@code p},
+     * the mean is {@code (r * p) / (1 - p)^2}.
      */
     @Override
     protected double calculateNumericalVariance() {
         final double p = getProbabilityOfSuccess();
         final double r = getNumberOfSuccesses();
         final double pInv = 1 - p;
-        return ( r * p ) / (pInv * pInv);
+        return (r * p) / (pInv * pInv);
     }
 
     /**
      * {@inheritDoc}
+     *
+     * Always returns {@code false}.
+     *
+     * @see {@link PascalDistribution#getSupportUpperBound() getSupportUpperBound()}
      */
     @Override
     public boolean isSupportUpperBoundInclusive() {

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PoissonDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PoissonDistributionImpl.java?rev=1206421&r1=1206420&r2=1206421&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PoissonDistributionImpl.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PoissonDistributionImpl.java
Sat Nov 26 10:17:49 2011
@@ -85,7 +85,7 @@ public class PoissonDistributionImpl ext
             throw new NotStrictlyPositiveException(LocalizedFormats.MEAN, p);
         }
         mean = p;
-        normal = new NormalDistributionImpl(p, FastMath.sqrt(p));
+        normal = new NormalDistribution(p, FastMath.sqrt(p));
         this.epsilon = epsilon;
         this.maxIterations = maxIterations;
     }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomDataImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomDataImpl.java?rev=1206421&r1=1206420&r2=1206421&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomDataImpl.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomDataImpl.java
Sat Nov 26 10:17:49 2011
@@ -32,7 +32,7 @@ import org.apache.commons.math.distribut
 import org.apache.commons.math.distribution.FDistribution;
 import org.apache.commons.math.distribution.HypergeometricDistribution;
 import org.apache.commons.math.distribution.IntegerDistribution;
-import org.apache.commons.math.distribution.PascalDistributionImpl;
+import org.apache.commons.math.distribution.PascalDistribution;
 import org.apache.commons.math.distribution.TDistributionImpl;
 import org.apache.commons.math.distribution.WeibullDistributionImpl;
 import org.apache.commons.math.distribution.ZipfDistributionImpl;
@@ -770,7 +770,7 @@ public class RandomDataImpl implements R
     }
 
     /**
-     * Generates a random value from the {@link PascalDistributionImpl Pascal Distribution}.
+     * Generates a random value from the {@link PascalDistribution Pascal Distribution}.
      * This implementation uses {@link #nextInversionDeviate(IntegerDistribution) inversion}
      * to generate random values.
      *
@@ -780,7 +780,7 @@ public class RandomDataImpl implements R
      * @since 2.2
      */
     public int nextPascal(int r, double p) {
-        return nextInversionDeviate(new PascalDistributionImpl(r, p));
+        return nextInversionDeviate(new PascalDistribution(r, p));
     }
 
     /**

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/MannWhitneyUTestImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/MannWhitneyUTestImpl.java?rev=1206421&r1=1206420&r2=1206421&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/MannWhitneyUTestImpl.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/MannWhitneyUTestImpl.java
Sat Nov 26 10:17:49 2011
@@ -17,7 +17,7 @@
 package org.apache.commons.math.stat.inference;
 
 import org.apache.commons.math.MathException;
-import org.apache.commons.math.distribution.NormalDistributionImpl;
+import org.apache.commons.math.distribution.NormalDistribution;
 import org.apache.commons.math.stat.ranking.NaNStrategy;
 import org.apache.commons.math.stat.ranking.NaturalRanking;
 import org.apache.commons.math.stat.ranking.TiesStrategy;
@@ -159,7 +159,7 @@ public class MannWhitneyUTestImpl implem
 
         final double z = (Umin - EU) / FastMath.sqrt(VarU);
 
-        final NormalDistributionImpl standardNormal = new NormalDistributionImpl(
+        final NormalDistribution standardNormal = new NormalDistribution(
                 0, 1);
 
         return 2 * standardNormal.cumulativeProbability(z);

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/WilcoxonSignedRankTestImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/WilcoxonSignedRankTestImpl.java?rev=1206421&r1=1206420&r2=1206421&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/WilcoxonSignedRankTestImpl.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/WilcoxonSignedRankTestImpl.java
Sat Nov 26 10:17:49 2011
@@ -17,7 +17,7 @@
 package org.apache.commons.math.stat.inference;
 
 import org.apache.commons.math.MathException;
-import org.apache.commons.math.distribution.NormalDistributionImpl;
+import org.apache.commons.math.distribution.NormalDistribution;
 import org.apache.commons.math.stat.ranking.NaNStrategy;
 import org.apache.commons.math.stat.ranking.NaturalRanking;
 import org.apache.commons.math.stat.ranking.TiesStrategy;
@@ -228,7 +228,7 @@ public class WilcoxonSignedRankTestImpl 
         // - 0.5 is a continuity correction
         final double z = (Wmin - ES - 0.5) / FastMath.sqrt(VarS);
 
-        final NormalDistributionImpl standardNormal = new NormalDistributionImpl(0, 1);
+        final NormalDistribution standardNormal = new NormalDistribution(0, 1);
 
         return 2*standardNormal.cumulativeProbability(z);
     }

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/CauchyDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/CauchyDistributionTest.java?rev=1206421&r1=1206420&r2=1206421&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/CauchyDistributionTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/CauchyDistributionTest.java
Sat Nov 26 10:17:49 2011
@@ -31,7 +31,7 @@ import org.junit.Test;
 public class CauchyDistributionTest extends ContinuousDistributionAbstractTest  {
 
     // --------------------- Override tolerance  --------------
-    protected double defaultTolerance = NormalDistributionImpl.DEFAULT_INVERSE_ABSOLUTE_ACCURACY;
+    protected double defaultTolerance = NormalDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY;
     @Override
     public void setUp() throws Exception {
         super.setUp();

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/NormalDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/NormalDistributionTest.java?rev=1206421&r1=1206420&r2=1206421&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/NormalDistributionTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/NormalDistributionTest.java
Sat Nov 26 10:17:49 2011
@@ -35,7 +35,7 @@ public class NormalDistributionTest exte
     /** Creates the default continuous distribution instance to use in tests. */
     @Override
     public NormalDistribution makeDistribution() {
-        return new NormalDistributionImpl(2.1, 1.4);
+        return new NormalDistribution(2.1, 1.4);
     }
 
     /** Creates the default cumulative probability distribution test input values */
@@ -61,7 +61,7 @@ public class NormalDistributionTest exte
     }
 
     // --------------------- Override tolerance  --------------
-    protected double defaultTolerance = NormalDistributionImpl.DEFAULT_INVERSE_ABSOLUTE_ACCURACY;
+    protected double defaultTolerance = NormalDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY;
     @Override
     public void setUp() throws Exception {
         super.setUp();
@@ -90,13 +90,13 @@ public class NormalDistributionTest exte
         verifyQuantiles();
         verifyDensities();
 
-        setDistribution(new NormalDistributionImpl(0, 1));
+        setDistribution(new NormalDistribution(0, 1));
         setDensityTestValues(new double[] {0.0539909665132, 0.241970724519, 0.398942280401,
0.241970724519, 0.0539909665132,
                 0.00443184841194, 0.000133830225765, 1.48671951473e-06});
         verifyQuantiles();
         verifyDensities();
 
-        setDistribution(new NormalDistributionImpl(0, 0.1));
+        setDistribution(new NormalDistribution(0, 0.1));
         setDensityTestValues(new double[] {0.539909665132, 2.41970724519, 3.98942280401,
2.41970724519,
                 0.539909665132, 0.0443184841194, 0.00133830225765, 1.48671951473e-05});
         verifyQuantiles();
@@ -125,7 +125,7 @@ public class NormalDistributionTest exte
 
     @Test(expected=NotStrictlyPositiveException.class)
     public void testPreconditions() {
-        new NormalDistributionImpl(1, 0);
+        new NormalDistribution(1, 0);
     }
 
     @Test
@@ -138,7 +138,7 @@ public class NormalDistributionTest exte
     }
 
     private void checkDensity(double mean, double sd, double[] x, double[] expected) {
-        NormalDistribution d = new NormalDistributionImpl(mean, sd);
+        NormalDistribution d = new NormalDistribution(mean, sd);
         for (int i = 0; i < x.length; i++) {
             Assert.assertEquals(expected[i], d.density(x[i]), 1e-9);
         }
@@ -150,11 +150,11 @@ public class NormalDistributionTest exte
      */
     @Test
     public void testExtremeValues() throws Exception {
-        NormalDistribution distribution = new NormalDistributionImpl(0, 1);
+        NormalDistribution distribution = new NormalDistribution(0, 1);
         for (int i = 0; i < 100; i++) { // make sure no convergence exception
             double lowerTail = distribution.cumulativeProbability(-i);
             double upperTail = distribution.cumulativeProbability(i);
-            if (i < 9) { // make sure not top-coded 
+            if (i < 9) { // make sure not top-coded
                 // For i = 10, due to bad tail precision in erf (MATH-364), 1 is returned
                 // TODO: once MATH-364 is resolved, replace 9 with 30
                 Assert.assertTrue(lowerTail > 0.0d);
@@ -165,17 +165,17 @@ public class NormalDistributionTest exte
                 Assert.assertTrue(upperTail > 0.99999);
             }
         }
-        
+
         Assert.assertEquals(distribution.cumulativeProbability(Double.MAX_VALUE), 1, 0);
         Assert.assertEquals(distribution.cumulativeProbability(-Double.MAX_VALUE), 0, 0);
         Assert.assertEquals(distribution.cumulativeProbability(Double.POSITIVE_INFINITY),
1, 0);
         Assert.assertEquals(distribution.cumulativeProbability(Double.NEGATIVE_INFINITY),
0, 0);
-        
+
    }
 
     @Test
     public void testMath280() {
-        NormalDistribution normal = new NormalDistributionImpl(0,1);
+        NormalDistribution normal = new NormalDistribution(0,1);
         double result = normal.inverseCumulativeProbability(0.9986501019683698);
         Assert.assertEquals(3.0, result, defaultTolerance);
         result = normal.inverseCumulativeProbability(0.841344746068543);
@@ -190,16 +190,16 @@ public class NormalDistributionTest exte
     public void testMoments() {
         final double tol = 1e-9;
         NormalDistribution dist;
-        
-        dist = new NormalDistributionImpl(0, 1);        
+
+        dist = new NormalDistribution(0, 1);
         Assert.assertEquals(dist.getNumericalMean(), 0, tol);
-        Assert.assertEquals(dist.getNumericalVariance(), 1, tol);        
- 
-        dist = new NormalDistributionImpl(2.2, 1.4);
+        Assert.assertEquals(dist.getNumericalVariance(), 1, tol);
+
+        dist = new NormalDistribution(2.2, 1.4);
         Assert.assertEquals(dist.getNumericalMean(), 2.2, tol);
         Assert.assertEquals(dist.getNumericalVariance(), 1.4 * 1.4, tol);
-        
-        dist = new NormalDistributionImpl(-2000.9, 10.4);
+
+        dist = new NormalDistribution(-2000.9, 10.4);
         Assert.assertEquals(dist.getNumericalMean(), -2000.9, tol);
         Assert.assertEquals(dist.getNumericalVariance(), 10.4 * 10.4, tol);
     }

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/PascalDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/PascalDistributionTest.java?rev=1206421&r1=1206420&r2=1206421&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/PascalDistributionTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/PascalDistributionTest.java
Sat Nov 26 10:17:49 2011
@@ -29,7 +29,7 @@ import org.junit.Test;
 public class PascalDistributionTest extends IntegerDistributionAbstractTest {
 
     // --------------------- Override tolerance  --------------
-    protected double defaultTolerance = NormalDistributionImpl.DEFAULT_INVERSE_ABSOLUTE_ACCURACY;
+    protected double defaultTolerance = NormalDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY;
     @Override
     public void setUp() {
         super.setUp();
@@ -41,7 +41,7 @@ public class PascalDistributionTest exte
     /** Creates the default discrete distribution instance to use in tests. */
     @Override
     public IntegerDistribution makeDistribution() {
-        return new PascalDistributionImpl(10,0.70);
+        return new PascalDistribution(10,0.70);
     }
 
     /** Creates the default probability density test input values */
@@ -90,7 +90,7 @@ public class PascalDistributionTest exte
     /** Test degenerate case p = 0   */
     @Test
     public void testDegenerate0() throws Exception {
-        setDistribution(new PascalDistributionImpl(5,0.0d));
+        setDistribution(new PascalDistribution(5,0.0d));
         setCumulativeTestPoints(new int[] {-1, 0, 1, 5, 10 });
         setCumulativeTestValues(new double[] {0d, 0d, 0d, 0d, 0d});
         setDensityTestPoints(new int[] {-1, 0, 1, 10, 11});
@@ -105,7 +105,7 @@ public class PascalDistributionTest exte
     /** Test degenerate case p = 1   */
     @Test
     public void testDegenerate1() throws Exception {
-        setDistribution(new PascalDistributionImpl(5,1.0d));
+        setDistribution(new PascalDistribution(5,1.0d));
         setCumulativeTestPoints(new int[] {-1, 0, 1, 2, 5, 10 });
         setCumulativeTestValues(new double[] {0d, 1d, 1d, 1d, 1d, 1d});
         setDensityTestPoints(new int[] {-1, 0, 1, 2, 5, 10});
@@ -121,12 +121,12 @@ public class PascalDistributionTest exte
     public void testMoments() {
         final double tol = 1e-9;
         PascalDistribution dist;
-        
-        dist = new PascalDistributionImpl(10, 0.5);
+
+        dist = new PascalDistribution(10, 0.5);
         Assert.assertEquals(dist.getNumericalMean(), ( 10d * 0.5d ) / 0.5d, tol);
-        Assert.assertEquals(dist.getNumericalVariance(), ( 10d * 0.5d ) / (0.5d * 0.5d),
tol); 
-        
-        dist = new PascalDistributionImpl(25, 0.3);
+        Assert.assertEquals(dist.getNumericalVariance(), ( 10d * 0.5d ) / (0.5d * 0.5d),
tol);
+
+        dist = new PascalDistribution(25, 0.3);
         Assert.assertEquals(dist.getNumericalMean(), ( 25d * 0.3d ) / 0.7d, tol);
         Assert.assertEquals(dist.getNumericalVariance(), ( 25d * 0.3d ) / (0.7d * 0.7d),
tol);
     }

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/RandomDataTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/RandomDataTest.java?rev=1206421&r1=1206420&r2=1206421&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/RandomDataTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/RandomDataTest.java
Sat Nov 26 10:17:49 2011
@@ -35,7 +35,7 @@ import org.apache.commons.math.distribut
 import org.apache.commons.math.distribution.GammaDistribution;
 import org.apache.commons.math.distribution.HypergeometricDistribution;
 import org.apache.commons.math.distribution.HypergeometricDistributionTest;
-import org.apache.commons.math.distribution.PascalDistributionImpl;
+import org.apache.commons.math.distribution.PascalDistribution;
 import org.apache.commons.math.distribution.PascalDistributionTest;
 import org.apache.commons.math.distribution.PoissonDistribution;
 import org.apache.commons.math.distribution.PoissonDistributionImpl;
@@ -1015,7 +1015,7 @@ public class RandomDataTest {
         double[] densityValues = testInstance.makeDensityTestValues();
         int sampleSize = 1000;
         int length = TestUtils.eliminateZeroMassPoints(densityPoints, densityValues);
-        PascalDistributionImpl distribution = (PascalDistributionImpl) testInstance.makeDistribution();
+        PascalDistribution distribution = (PascalDistribution) testInstance.makeDistribution();
         double[] expectedCounts = new double[length];
         long[] observedCounts = new long[length];
         for (int i = 0; i < length; i++) {



Mime
View raw message