commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r1003512 [1/2] - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math/distribution/ main/java/org/apache/commons/math/exception/util/ main/resources/META-INF/localization/ site/xdoc/ test/java/org/apache/commons/math/distrib...
Date Fri, 01 Oct 2010 12:46:17 GMT
Author: erans
Date: Fri Oct  1 12:46:16 2010
New Revision: 1003512

URL: http://svn.apache.org/viewvc?rev=1003512&view=rev
Log:
Removed deprecated code in implementations of "IntegerDistribution".
Added "final" keyword.
Added "sample" methods to "IntegerDistribution" and "ContinuousDistribution"
interfaces.
Cleaned up Javadoc.

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractIntegerDistribution.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BetaDistributionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BinomialDistribution.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BinomialDistributionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/CauchyDistributionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistributionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ContinuousDistribution.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/FDistributionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/GammaDistributionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/HypergeometricDistribution.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/HypergeometricDistributionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/IntegerDistribution.java
    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
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PascalDistributionImpl.java
    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/distribution/TDistributionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/WeibullDistributionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ZipfDistribution.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ZipfDistributionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/util/LocalizedFormats.java
    commons/proper/math/trunk/src/main/resources/META-INF/localization/LocalizedFormats_fr.properties
    commons/proper/math/trunk/src/site/xdoc/changes.xml
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/HypergeometricDistributionTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ZipfDistributionTest.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractIntegerDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractIntegerDistribution.java?rev=1003512&r1=1003511&r2=1003512&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractIntegerDistribution.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractIntegerDistribution.java Fri Oct  1 12:46:16 2010
@@ -20,7 +20,9 @@ import java.io.Serializable;
 
 import org.apache.commons.math.FunctionEvaluationException;
 import org.apache.commons.math.MathException;
-import org.apache.commons.math.MathRuntimeException;
+import org.apache.commons.math.exception.NotStrictlyPositiveException;
+import org.apache.commons.math.exception.NumberIsTooSmallException;
+import org.apache.commons.math.exception.OutOfRangeException;
 import org.apache.commons.math.exception.util.LocalizedFormats;
 import org.apache.commons.math.random.RandomDataImpl;
 import org.apache.commons.math.util.FastMath;
@@ -35,12 +37,10 @@ import org.apache.commons.math.util.Fast
  */
 public abstract class AbstractIntegerDistribution extends AbstractDistribution
     implements IntegerDistribution, Serializable {
-
    /** Serializable version identifier */
     private static final long serialVersionUID = -1146319659338487221L;
-
     /**
-     * RandomData instance used to generate samples from the distribution
+     * RandomData instance used to generate samples from the distribution.
      * @since 2.2
      */
     protected final RandomDataImpl randomData = new RandomDataImpl();
@@ -48,22 +48,19 @@ public abstract class AbstractIntegerDis
     /**
      * Default constructor.
      */
-    protected AbstractIntegerDistribution() {
-        super();
-    }
+    protected AbstractIntegerDistribution() {}
 
     /**
-     * For a random variable X whose values are distributed according
-     * to this distribution, this method returns P(X ≤ x).  In other words,
-     * this method represents the  (cumulative) distribution function, or
-     * CDF, for this distribution.
-     * <p>
-     * If <code>x</code> does not represent an integer value, the CDF is
-     * evaluated at the greatest integer less than x.
-     *
-     * @param x the value at which the distribution function is evaluated.
-     * @return cumulative probability that a random variable with this
-     * distribution takes a value less than or equal to <code>x</code>
+     * 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,
+     * or CDF, for this distribution.
+     * If {@code x} does not represent an integer value, the CDF is
+     * evaluated at the greatest integer less than {@code x}.
+     *
+     * @param x Value at which the distribution function is evaluated.
+     * @return the cumulative probability that a random variable with this
+     * distribution takes a value less than or equal to {@code x}.
      * @throws MathException if the cumulative probability can not be
      * computed due to convergence or other numerical errors.
      */
@@ -72,24 +69,25 @@ public abstract class AbstractIntegerDis
     }
 
     /**
-     * For a random variable X whose values are distributed according
-     * to this distribution, this method returns P(x0 &le; X &le; x1).
+     * For a random variable {@code X} whose values are distributed
+     * according to this distribution, this method returns
+     * {@code P(x0 < X < x1)}.
      *
-     * @param x0 the (inclusive) lower bound
-     * @param x1 the (inclusive) upper bound
+     * @param x0 Inclusive lower bound.
+     * @param x1 Inclusive upper bound.
      * @return the probability that a random variable with this distribution
-     * will take a value between <code>x0</code> and <code>x1</code>,
+     * will take a value between {@code x0} and {@code x1},
      * including the endpoints.
      * @throws MathException if the cumulative probability can not be
      * computed due to convergence or other numerical errors.
-     * @throws IllegalArgumentException if <code>x0 > x1</code>
+     * @throws NumberIsTooSmallException if {@code x1 > x0}.
      */
     @Override
     public double cumulativeProbability(double x0, double x1)
         throws MathException {
-        if (x0 > x1) {
-            throw MathRuntimeException.createIllegalArgumentException(
-                  LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1);
+        if (x1 < x0) {
+            throw new NumberIsTooSmallException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT,
+                                                x0, x1, true);
         }
         if (FastMath.floor(x0) < x0) {
             return cumulativeProbability(((int) FastMath.floor(x0)) + 1,
@@ -101,27 +99,27 @@ public abstract class AbstractIntegerDis
     }
 
     /**
-     * For a random variable X whose values are distributed according
-     * to this distribution, this method returns P(X &le; x).  In other words,
-     * this method represents the probability distribution function, or PDF,
-     * for this distribution.
+     * 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 probability distribution function,
+     * or PDF, for this distribution.
      *
-     * @param x the value at which the PDF is evaluated.
+     * @param x Value at which the PDF is evaluated.
      * @return PDF for this distribution.
      * @throws MathException if the cumulative probability can not be
-     *            computed due to convergence or other numerical errors.
+     * computed due to convergence or other numerical errors.
      */
     public abstract double cumulativeProbability(int x) throws MathException;
 
     /**
-     * For a random variable X whose values are distributed according
-     * to this distribution, this method returns P(X = x). In other words, this
-     * method represents the probability mass function,  or PMF, for the distribution.
-     * <p>
-     * If <code>x</code> does not represent an integer value, 0 is returned.
+     * 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 probability mass function, or PMF,
+     * for the distribution.
+     * If {@code x} does not represent an integer value, 0 is returned.
      *
-     * @param x the value at which the probability density function is evaluated
-     * @return the value of the probability density function at x
+     * @param x Value at which the probability density function is evaluated.
+     * @return the value of the probability density function at {@code x}.
      */
     public double probability(double x) {
         double fl = FastMath.floor(x);
@@ -133,39 +131,38 @@ public abstract class AbstractIntegerDis
     }
 
     /**
-    * For a random variable X whose values are distributed according
-     * to this distribution, this method returns P(x0 &le; X &le; x1).
+     * For a random variable {@code X} whose values are distributed according
+     * to this distribution, this method returns {@code P(x0 < X < x1)}.
      *
-     * @param x0 the inclusive, lower bound
-     * @param x1 the inclusive, upper bound
+     * @param x0 Inclusive lower bound.
+     * @param x1 Inclusive upper bound.
      * @return the cumulative probability.
      * @throws MathException if the cumulative probability can not be
-     *            computed due to convergence or other numerical errors.
-     * @throws IllegalArgumentException if x0 > x1
+     * computed due to convergence or other numerical errors.
+     * @throws NumberIsTooSmallException {@code if x0 > x1}.
      */
     public double cumulativeProbability(int x0, int x1) throws MathException {
-        if (x0 > x1) {
-            throw MathRuntimeException.createIllegalArgumentException(
-                  LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1);
+        if (x1 < x0) {
+            throw new NumberIsTooSmallException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT,
+                                                x0, x1, true);
         }
         return cumulativeProbability(x1) - cumulativeProbability(x0 - 1);
     }
 
     /**
-     * For a random variable X whose values are distributed according
-     * to this distribution, this method returns the largest x, such
-     * that P(X &le; x) &le; <code>p</code>.
+     * For a random variable {@code X} whose values are distributed according
+     * to this distribution, this method returns the largest {@code x}, such
+     * that {@code P(X < x) < p}.
      *
-     * @param p the desired probability
-     * @return the largest x such that P(X &le; x) <= p
+     * @param p Desired probability.
+     * @return the largest {@code x} such that {@code P(X < x) <= p}.
      * @throws MathException if the inverse cumulative probability can not be
-     *            computed due to convergence or other numerical errors.
-     * @throws IllegalArgumentException if p < 0 or p > 1
+     * computed due to convergence or other numerical errors.
+     * @throws OutOfRangeException if {@code p < 0} or {@code p > 1}.
      */
     public int inverseCumulativeProbability(final double p) throws MathException{
-        if (p < 0.0 || p > 1.0) {
-            throw MathRuntimeException.createIllegalArgumentException(
-                  LocalizedFormats.OUT_OF_RANGE_SIMPLE, p, 0.0, 1.0);
+        if (p < 0 || p > 1) {
+            throw new OutOfRangeException(p, 0, 1);
         }
 
         // by default, do simple bisection.
@@ -210,10 +207,7 @@ public abstract class AbstractIntegerDis
     }
 
     /**
-     * Reseeds the random generator used to generate samples.
-     *
-     * @param seed the new seed
-     * @since 2.2
+     * {@inheritDoc}
      */
     public void reseedRandomGenerator(long seed) {
         randomData.reSeed(seed);
@@ -222,29 +216,33 @@ public abstract class AbstractIntegerDis
     /**
      * Generates a random value sampled from this distribution. The default
      * implementation uses the
-     * <a href="http://en.wikipedia.org/wiki/Inverse_transform_sampling"> inversion method.</a>
+     * <a href="http://en.wikipedia.org/wiki/Inverse_transform_sampling">
+     *  inversion method.
+     * </a>
      *
-     * @return random value
+     * @return a random value.
      * @since 2.2
-     * @throws MathException if an error occurs generating the random value
+     * @throws MathException if an error occurs generating the random value.
      */
     public int sample() throws MathException {
         return randomData.nextInversionDeviate(this);
     }
 
     /**
-     * Generates a random sample from the distribution.  The default implementation
-     * generates the sample by calling {@link #sample()} in a loop.
+     * Generates a random sample from the distribution.  The default
+     * implementation generates the sample by calling {@link #sample()}
+     * in a loop.
      *
-     * @param sampleSize number of random values to generate
+     * @param sampleSize number of random values to generate.
      * @since 2.2
-     * @return an array representing the random sample
-     * @throws MathException if an error occurs generating the sample
-     * @throws IllegalArgumentException if sampleSize is not positive
+     * @return an array representing the random sample.
+     * @throws MathException if an error occurs generating the sample.
+     * @throws NotStrictlyPositiveException if {@code sampleSize <= 0}.
      */
     public int[] sample(int sampleSize) throws MathException {
         if (sampleSize <= 0) {
-            MathRuntimeException.createIllegalArgumentException(LocalizedFormats.NOT_POSITIVE_SAMPLE_SIZE, sampleSize);
+            throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES,
+                                                   sampleSize);
         }
         int[] out = new int[sampleSize];
         for (int i = 0; i < sampleSize; i++) {
@@ -254,16 +252,21 @@ public abstract class AbstractIntegerDis
     }
 
     /**
-     * Computes the cumulative probability function and checks for NaN values returned.
-     * Throws MathException if the value is NaN. Wraps and rethrows any MathException encountered
-     * evaluating the cumulative probability function in a FunctionEvaluationException. Throws
-     * FunctionEvaluationException of the cumulative probability function returns NaN.
-     *
-     * @param argument input value
-     * @return cumulative probability
-     * @throws FunctionEvaluationException if a MathException occurs computing the cumulative probability
+     * Computes the cumulative probability function and checks for NaN
+     * values returned.
+     * Throws MathException if the value is NaN. Wraps and rethrows any
+     * MathException encountered evaluating the cumulative probability
+     * function in a FunctionEvaluationException.
+     * Throws FunctionEvaluationException of the cumulative probability
+     * function returns NaN.
+     *
+     * @param argument Input value.
+     * @return the cumulative probability.
+     * @throws FunctionEvaluationException if a MathException occurs
+     * computing the cumulative probability.
      */
-    private double checkedCumulativeProbability(int argument) throws FunctionEvaluationException {
+    private double checkedCumulativeProbability(int argument)
+        throws FunctionEvaluationException {
         double result = Double.NaN;
         try {
             result = cumulativeProbability(argument);
@@ -278,24 +281,22 @@ public abstract class AbstractIntegerDis
     }
 
     /**
-     * Access the domain value lower bound, based on <code>p</code>, used to
+     * Access the domain value lower bound, based on {@code p}, used to
      * bracket a PDF root.  This method is used by
      * {@link #inverseCumulativeProbability(double)} to find critical values.
      *
-     * @param p the desired probability for the critical value
-     * @return domain value lower bound, i.e.
-     *         P(X &lt; <i>lower bound</i>) &lt; <code>p</code>
+     * @param p Desired probability for the critical value
+     * @return the domain value lower bound, i.e. {@code P(X < 'lower bound') < p}.
      */
     protected abstract int getDomainLowerBound(double p);
 
     /**
-     * Access the domain value upper bound, based on <code>p</code>, used to
+     * Access the domain value upper bound, based on {@code p}, used to
      * bracket a PDF root.  This method is used by
      * {@link #inverseCumulativeProbability(double)} to find critical values.
      *
-     * @param p the desired probability for the critical value
-     * @return domain value upper bound, i.e.
-     *         P(X &lt; <i>upper bound</i>) &gt; <code>p</code>
+     * @param p Desired probability for the critical value.
+     * @return the domain value upper bound, i.e. {@code P(X < 'upper bound') > p}.
      */
     protected abstract int getDomainUpperBound(double p);
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BetaDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BetaDistributionImpl.java?rev=1003512&r1=1003511&r2=1003512&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BetaDistributionImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BetaDistributionImpl.java Fri Oct  1 12:46:16 2010
@@ -37,28 +37,22 @@ import org.apache.commons.math.util.Fast
  */
 public class BetaDistributionImpl
     extends AbstractContinuousDistribution implements BetaDistribution {
-
     /**
-     * Default inverse cumulative probability accurac
+     * Default inverse cumulative probability accuracy.
      * @since 2.1
      */
     public static final double DEFAULT_INVERSE_ABSOLUTE_ACCURACY = 1e-9;
-
     /** Serializable version identifier. */
     private static final long serialVersionUID = -1221965979403477668L;
-
     /** First shape parameter. */
-    private double alpha;
-
+    private final double alpha;
     /** Second shape parameter. */
-    private double beta;
-
+    private final double beta;
     /** Normalizing factor used in density computations.
      * updated whenever alpha or beta are changed.
      */
     private double z;
-
-    /** Inverse cumulative probability accuracy */
+    /** Inverse cumulative probability accuracy. */
     private final double solverAbsoluteAccuracy;
 
     /**

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BinomialDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BinomialDistribution.java?rev=1003512&r1=1003511&r2=1003512&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BinomialDistribution.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BinomialDistribution.java Fri Oct  1 12:46:16 2010
@@ -32,29 +32,15 @@ package org.apache.commons.math.distribu
 public interface BinomialDistribution extends IntegerDistribution {
     /**
      * Access the number of trials for this distribution.
+     *
      * @return the number of trials.
      */
     int getNumberOfTrials();
 
     /**
      * Access the probability of success for this distribution.
+     *
      * @return the probability of success.
      */
     double getProbabilityOfSuccess();
-
-    /**
-     * Change the number of trials for this distribution.
-     * @param trials the new number of trials.
-     * @deprecated as of v2.1
-     */
-    @Deprecated
-    void setNumberOfTrials(int trials);
-
-    /**
-     * Change the probability of success for this distribution.
-     * @param p the new probability of success.
-     * @deprecated as of v2.1
-     */
-    @Deprecated
-    void setProbabilityOfSuccess(double p);
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BinomialDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BinomialDistributionImpl.java?rev=1003512&r1=1003511&r2=1003512&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BinomialDistributionImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BinomialDistributionImpl.java Fri Oct  1 12:46:16 2010
@@ -19,7 +19,8 @@ package org.apache.commons.math.distribu
 import java.io.Serializable;
 
 import org.apache.commons.math.MathException;
-import org.apache.commons.math.MathRuntimeException;
+import org.apache.commons.math.exception.OutOfRangeException;
+import org.apache.commons.math.exception.NotPositiveException;
 import org.apache.commons.math.exception.util.LocalizedFormats;
 import org.apache.commons.math.special.Beta;
 import org.apache.commons.math.util.FastMath;
@@ -31,108 +32,55 @@ import org.apache.commons.math.util.Fast
  */
 public class BinomialDistributionImpl extends AbstractIntegerDistribution
         implements BinomialDistribution, Serializable {
-
-    /** Serializable version identifier */
+    /** Serializable version identifier. */
     private static final long serialVersionUID = 6751309484392813623L;
-
     /** The number of trials. */
-    private int numberOfTrials;
-
+    private final int numberOfTrials;
     /** The probability of success. */
-    private double probabilityOfSuccess;
+    private final double probabilityOfSuccess;
 
     /**
      * Create a binomial distribution with the given number of trials and
      * probability of success.
      *
-     * @param trials the number of trials.
-     * @param p the probability of success.
+     * @param trials Number of trials.
+     * @param p Probability of success.
+     * @throws NotPositiveException if {@code trials < 0}.
+     * @throws OutOfRangeException if {@code p < 0} or {@code p > 1}.
      */
     public BinomialDistributionImpl(int trials, double p) {
-        super();
-        setNumberOfTrialsInternal(trials);
-        setProbabilityOfSuccessInternal(p);
+        if (trials < 0) {
+            throw new NotPositiveException(LocalizedFormats.NUMBER_OF_TRIALS,
+                                           trials);
+        }
+        if (p < 0 || p > 1) {
+            throw new OutOfRangeException(p, 0, 1);
+        }
+
+        probabilityOfSuccess = p;
+        numberOfTrials = trials;
     }
 
     /**
-     * Access the number of trials for this distribution.
-     *
-     * @return the number of trials.
+     * {@inheritDoc}
      */
     public int getNumberOfTrials() {
         return numberOfTrials;
     }
 
     /**
-     * Access the probability of success for this distribution.
-     *
-     * @return the probability of success.
+     * {@inheritDoc}
      */
     public double getProbabilityOfSuccess() {
         return probabilityOfSuccess;
     }
 
     /**
-     * Change the number of trials for this distribution.
-     *
-     * @param trials the new number of trials.
-     * @throws IllegalArgumentException if <code>trials</code> is not a valid
-     *             number of trials.
-     * @deprecated as of 2.1 (class will become immutable in 3.0)
-     */
-    @Deprecated
-    public void setNumberOfTrials(int trials) {
-        setNumberOfTrialsInternal(trials);
-    }
-    /**
-     * Change the number of trials for this distribution.
-     *
-     * @param trials the new number of trials.
-     * @throws IllegalArgumentException if <code>trials</code> is not a valid
-     *             number of trials.
-     */
-    private void setNumberOfTrialsInternal(int trials) {
-        if (trials < 0) {
-            throw MathRuntimeException.createIllegalArgumentException(
-                    LocalizedFormats.NEGATIVE_NUMBER_OF_TRIALS, trials);
-        }
-        numberOfTrials = trials;
-    }
-
-    /**
-     * Change the probability of success for this distribution.
-     *
-     * @param p the new probability of success.
-     * @throws IllegalArgumentException if <code>p</code> is not a valid
-     *             probability.
-     * @deprecated as of 2.1 (class will become immutable in 3.0)
-     */
-    @Deprecated
-    public void setProbabilityOfSuccess(double p) {
-        setProbabilityOfSuccessInternal(p);
-    }
-    /**
-     * Change the probability of success for this distribution.
-     *
-     * @param p the new probability of success.
-     * @throws IllegalArgumentException if <code>p</code> is not a valid
-     *             probability.
-     */
-    private void setProbabilityOfSuccessInternal(double p) {
-        if (p < 0.0 || p > 1.0) {
-            throw MathRuntimeException.createIllegalArgumentException(
-                    LocalizedFormats.OUT_OF_RANGE_SIMPLE, p, 0.0, 1.0);
-        }
-        probabilityOfSuccess = p;
-    }
-
-    /**
-     * Access the domain value lower bound, based on <code>p</code>, used to
+     * Access the domain value lower bound, based on {@code p}, used to
      * bracket a PDF root.
      *
-     * @param p the desired probability for the critical value
-     * @return domain value lower bound, i.e. P(X &lt; <i>lower bound</i>) &lt;
-     *         <code>p</code>
+     * @param p Desired probability for the critical value.
+     * @return the domain value lower bound, i.e. {@code P(X < 'lower bound') < p}.
      */
     @Override
     protected int getDomainLowerBound(double p) {
@@ -140,12 +88,11 @@ public class BinomialDistributionImpl ex
     }
 
     /**
-     * Access the domain value upper bound, based on <code>p</code>, used to
+     * Access the domain value upper bound, based on {@code p}, used to
      * bracket a PDF root.
      *
-     * @param p the desired probability for the critical value
-     * @return domain value upper bound, i.e. P(X &lt; <i>upper bound</i>) &gt;
-     *         <code>p</code>
+     * @param p Desired probability for the critical value
+     * @return the domain value upper bound, i.e. {@code P(X < 'upper bound') > p}.
      */
     @Override
     protected int getDomainUpperBound(double p) {
@@ -153,12 +100,12 @@ public class BinomialDistributionImpl ex
     }
 
     /**
-     * For this distribution, X, this method returns P(X &le; x).
+     * For this distribution, {@code X}, this method returns {@code P(X < x)}.
      *
-     * @param x the value at which the PDF is evaluated.
+     * @param x Value at which the PDF is evaluated.
      * @return PDF for this distribution.
      * @throws MathException if the cumulative probability can not be computed
-     *             due to convergence or other numerical errors.
+     * due to convergence or other numerical errors.
      */
     @Override
     public double cumulativeProbability(int x) throws MathException {
@@ -175,9 +122,9 @@ public class BinomialDistributionImpl ex
     }
 
     /**
-     * For this distribution, X, this method returns P(X = x).
+     * For this distribution, {@code X}, this method returns {@code P(X = x)}.
      *
-     * @param x the value at which the PMF is evaluated.
+     * @param x Value at which the PMF is evaluated.
      * @return PMF for this distribution.
      */
     public double probability(int x) {
@@ -193,18 +140,15 @@ public class BinomialDistributionImpl ex
     }
 
     /**
-     * For this distribution, X, this method returns the largest x, such that
-     * P(X &le; x) &le; <code>p</code>.
-     * <p>
-     * Returns <code>-1</code> for p=0 and <code>Integer.MAX_VALUE</code> for
-     * p=1.
-     * </p>
+     * 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 the desired probability
-     * @return the largest x such that P(X &le; x) <= p
+     * @param p Desired probability.
+     * @return the largest {@code x} such that {@code P(X < x) <= p}.
      * @throws MathException if the inverse cumulative probability can not be
-     *             computed due to convergence or other numerical errors.
-     * @throws IllegalArgumentException if p < 0 or p > 1
+     * computed due to convergence or other numerical errors.
+     * @throws OutOfRangeException if {@code p < 0} or {@code p > 1}.
      */
     @Override
     public int inverseCumulativeProbability(final double p)

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/CauchyDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/CauchyDistributionImpl.java?rev=1003512&r1=1003511&r2=1003512&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/CauchyDistributionImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/CauchyDistributionImpl.java Fri Oct  1 12:46:16 2010
@@ -32,18 +32,18 @@ import org.apache.commons.math.util.Fast
  * @version $Revision$ $Date$
  */
 public class CauchyDistributionImpl extends AbstractContinuousDistribution
-        implements CauchyDistribution, Serializable {
+    implements CauchyDistribution, Serializable {
     /**
-     * Default inverse cumulative probability accuracy
+     * Default inverse cumulative probability accuracy.
      * @since 2.1
      */
     public static final double DEFAULT_INVERSE_ABSOLUTE_ACCURACY = 1e-9;
     /** Serializable version identifier */
     private static final long serialVersionUID = 8589540077390120676L;
     /** The median of this distribution. */
-    private double median = 0;
+    private final double median;
     /** The scale of this distribution. */
-    private double scale = 1;
+    private final double scale;
     /** Inverse cumulative probability accuracy */
     private final double solverAbsoluteAccuracy;
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistributionImpl.java?rev=1003512&r1=1003511&r2=1003512&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistributionImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistributionImpl.java Fri Oct  1 12:46:16 2010
@@ -36,7 +36,7 @@ public class ChiSquaredDistributionImpl
     /** Serializable version identifier */
     private static final long serialVersionUID = -8352658048349159782L;
     /** Internal Gamma distribution. */
-    private GammaDistribution gamma;
+    private final GammaDistribution gamma;
     /** Inverse cumulative probability accuracy */
     private final double solverAbsoluteAccuracy;
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ContinuousDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ContinuousDistribution.java?rev=1003512&r1=1003511&r2=1003512&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ContinuousDistribution.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ContinuousDistribution.java Fri Oct  1 12:46:16 2010
@@ -42,4 +42,33 @@ public interface ContinuousDistribution 
      * @return the pdf at point {@code x}.
      */
     double density(double x);
+
+    /**
+     * Reseed the random generator used to generate samples.
+     *
+     * @param seed New seed.
+     * @since 3.0
+     */
+    void reseedRandomGenerator(long seed);
+
+    /**
+     * Generate a random value sampled from this distribution.
+     *
+     * @return a random value.
+     * @throws MathException if an error occurs generating the random value.
+     * @since 3.0
+     */
+    double sample() throws MathException;
+
+    /**
+     * Generate a random sample from the distribution.
+     *
+     * @param sampleSize number of random values to generate.
+     * @return an array representing the random sample.
+     * @throws MathException if an error occurs generating the sample.
+     * @throws org.apache.commons.math.exception.NotStrictlyPositiveException
+     * if {@code sampleSize} is not positive.
+     * @since 3.0
+     */
+    double[] sample(int sampleSize) throws MathException;
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java?rev=1003512&r1=1003511&r2=1003512&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java Fri Oct  1 12:46:16 2010
@@ -32,15 +32,15 @@ import org.apache.commons.math.util.Fast
 public class ExponentialDistributionImpl extends AbstractContinuousDistribution
     implements ExponentialDistribution, Serializable {
     /**
-     * Default inverse cumulative probability accuracy
+     * Default inverse cumulative probability accuracy.
      * @since 2.1
      */
     public static final double DEFAULT_INVERSE_ABSOLUTE_ACCURACY = 1e-9;
     /** Serializable version identifier */
     private static final long serialVersionUID = 2401296428283614780L;
     /** The mean of this distribution. */
-    private double mean;
-    /** Inverse cumulative probability accuracy */
+    private final double mean;
+    /** Inverse cumulative probability accuracy. */
     private final double solverAbsoluteAccuracy;
 
     /**

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/FDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/FDistributionImpl.java?rev=1003512&r1=1003511&r2=1003512&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/FDistributionImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/FDistributionImpl.java Fri Oct  1 12:46:16 2010
@@ -35,17 +35,17 @@ public class FDistributionImpl
     extends AbstractContinuousDistribution
     implements FDistribution, Serializable  {
     /**
-     * Default inverse cumulative probability accuracy
+     * Default inverse cumulative probability accuracy.
      * @since 2.1
      */
     public static final double DEFAULT_INVERSE_ABSOLUTE_ACCURACY = 1e-9;
-    /** Serializable version identifier */
+    /** Serializable version identifier. */
     private static final long serialVersionUID = -8516354193418641566L;
-    /** The numerator degrees of freedom*/
-    private double numeratorDegreesOfFreedom;
-    /** The numerator degrees of freedom*/
-    private double denominatorDegreesOfFreedom;
-    /** Inverse cumulative probability accuracy */
+    /** The numerator degrees of freedom. */
+    private final double numeratorDegreesOfFreedom;
+    /** The numerator degrees of freedom. */
+    private final double denominatorDegreesOfFreedom;
+    /** Inverse cumulative probability accuracy. */
     private final double solverAbsoluteAccuracy;
 
     /**

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/GammaDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/GammaDistributionImpl.java?rev=1003512&r1=1003511&r2=1003512&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/GammaDistributionImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/GammaDistributionImpl.java Fri Oct  1 12:46:16 2010
@@ -31,23 +31,18 @@ import org.apache.commons.math.util.Fast
  */
 public class GammaDistributionImpl extends AbstractContinuousDistribution
     implements GammaDistribution, Serializable  {
-
     /**
-     * Default inverse cumulative probability accuracy
+     * Default inverse cumulative probability accuracy.
      * @since 2.1
      */
     public static final double DEFAULT_INVERSE_ABSOLUTE_ACCURACY = 1e-9;
-
-    /** Serializable version identifier */
+    /** Serializable version identifier. */
     private static final long serialVersionUID = -3239549463135430361L;
-
     /** The shape parameter. */
-    private double alpha;
-
+    private final double alpha;
     /** The scale parameter. */
-    private double beta;
-
-    /** Inverse cumulative probability accuracy */
+    private final double beta;
+    /** Inverse cumulative probability accuracy. */
     private final double solverAbsoluteAccuracy;
 
     /**

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/HypergeometricDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/HypergeometricDistribution.java?rev=1003512&r1=1003511&r2=1003512&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/HypergeometricDistribution.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/HypergeometricDistribution.java Fri Oct  1 12:46:16 2010
@@ -31,46 +31,24 @@ package org.apache.commons.math.distribu
  * @version $Revision$ $Date$
  */
 public interface HypergeometricDistribution extends IntegerDistribution {
-
     /**
      * Access the number of successes.
+     *
      * @return the number of successes.
      */
     int getNumberOfSuccesses();
 
     /**
      * Access the population size.
+     *
      * @return the population size.
      */
     int getPopulationSize();
 
     /**
      * Access the sample size.
+     *
      * @return the sample size.
      */
     int getSampleSize();
-
-    /**
-     * Modify the number of successes.
-     * @param num the new number of successes.
-     * @deprecated as of v2.1
-     */
-    @Deprecated
-    void setNumberOfSuccesses(int num);
-
-    /**
-     * Modify the population size.
-     * @param size the new population size.
-     * @deprecated as of v2.1
-     */
-    @Deprecated
-    void setPopulationSize(int size);
-
-    /**
-     * Modify the sample size.
-     * @param size the new sample size.
-     * @deprecated as of v2.1
-     */
-    @Deprecated
-    void setSampleSize(int size);
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/HypergeometricDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/HypergeometricDistributionImpl.java?rev=1003512&r1=1003511&r2=1003512&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/HypergeometricDistributionImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/HypergeometricDistributionImpl.java Fri Oct  1 12:46:16 2010
@@ -19,7 +19,9 @@ package org.apache.commons.math.distribu
 
 import java.io.Serializable;
 
-import org.apache.commons.math.MathRuntimeException;
+import org.apache.commons.math.exception.NotPositiveException;
+import org.apache.commons.math.exception.NotStrictlyPositiveException;
+import org.apache.commons.math.exception.NumberIsTooLargeException;
 import org.apache.commons.math.exception.util.LocalizedFormats;
 import org.apache.commons.math.util.MathUtils;
 import org.apache.commons.math.util.FastMath;
@@ -30,53 +32,64 @@ import org.apache.commons.math.util.Fast
  * @version $Revision$ $Date$
  */
 public class HypergeometricDistributionImpl extends AbstractIntegerDistribution
-        implements HypergeometricDistribution, Serializable {
-
-    /** Serializable version identifier */
+    implements HypergeometricDistribution, Serializable {
+    /** Serializable version identifier. */
     private static final long serialVersionUID = -436928820673516179L;
-
     /** The number of successes in the population. */
-    private int numberOfSuccesses;
-
+    private final int numberOfSuccesses;
     /** The population size. */
-    private int populationSize;
-
+    private final int populationSize;
     /** The sample size. */
-    private int sampleSize;
+    private final int sampleSize;
 
     /**
-     * Construct a new hypergeometric distribution with the given the population
-     * size, the number of successes in the population, and the sample size.
-     *
-     * @param populationSize the population size.
-     * @param numberOfSuccesses number of successes in the population.
-     * @param sampleSize the sample size.
+     * Construct a new hypergeometric distribution with the given the
+     * population size, the number of successes in the population, and
+     * the sample size.
+     *
+     * @param populationSize Population size.
+     * @param numberOfSuccesses Number of successes in the population.
+     * @param sampleSize Sample size.
+     * @throws NotPositiveException if {@code numberOfSuccesses < 0}.
+     * @throws NotStrictlyPositiveException if {@code populationSize <= 0}.
+     * @throws NotPositiveException if {@code populationSize < 0}.
+     * @throws NumberIsTooLargeException if {@code numberOfSuccesses > populationSize}.
+     * @throws NumberIsTooLargeException if {@code sampleSize > populationSize}.
      */
     public HypergeometricDistributionImpl(int populationSize,
-            int numberOfSuccesses, int sampleSize) {
-        super();
+                                          int numberOfSuccesses,
+                                          int sampleSize) {
+        if (populationSize <= 0) {
+            throw new NotStrictlyPositiveException(LocalizedFormats.POPULATION_SIZE,
+                                                   populationSize);
+        }
+        if (numberOfSuccesses < 0) {
+            throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SUCCESSES,
+                                           numberOfSuccesses);
+        }
+        if (sampleSize < 0) {
+            throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES,
+                                           sampleSize);
+        }
+
         if (numberOfSuccesses > populationSize) {
-            throw MathRuntimeException
-                    .createIllegalArgumentException(
-                            LocalizedFormats.NUMBER_OF_SUCCESS_LARGER_THAN_POPULATION_SIZE,
-                            numberOfSuccesses, populationSize);
+            throw new NumberIsTooLargeException(LocalizedFormats.NUMBER_OF_SUCCESS_LARGER_THAN_POPULATION_SIZE,
+                                                numberOfSuccesses, populationSize, true);
         }
         if (sampleSize > populationSize) {
-            throw MathRuntimeException
-                    .createIllegalArgumentException(
-                            LocalizedFormats.SAMPLE_SIZE_LARGER_THAN_POPULATION_SIZE,
-                            sampleSize, populationSize);
+            throw new NumberIsTooLargeException(LocalizedFormats.SAMPLE_SIZE_LARGER_THAN_POPULATION_SIZE,
+                                                sampleSize, populationSize, true);
         }
 
-        setPopulationSizeInternal(populationSize);
-        setSampleSizeInternal(sampleSize);
-        setNumberOfSuccessesInternal(numberOfSuccesses);
+        this.numberOfSuccesses = numberOfSuccesses;
+        this.populationSize = populationSize;
+        this.sampleSize = sampleSize;
     }
 
     /**
-     * For this distribution, X, this method returns P(X &le; x).
+     * For this distribution, {@code X}, this method returns {@code P(X < x)}.
      *
-     * @param x the value at which the PDF is evaluated.
+     * @param x Value at which the PDF is evaluated.
      * @return PDF for this distribution.
      */
     @Override
@@ -99,23 +112,22 @@ public class HypergeometricDistributionI
     /**
      * Return the domain for the given hypergeometric distribution parameters.
      *
-     * @param n the population size.
-     * @param m number of successes in the population.
-     * @param k the sample size.
+     * @param n Population size.
+     * @param m Number of successes in the population.
+     * @param k Sample size.
      * @return a two element array containing the lower and upper bounds of the
-     *         hypergeometric distribution.
+     * hypergeometric distribution.
      */
     private int[] getDomain(int n, int m, int k) {
         return new int[] { getLowerDomain(n, m, k), getUpperDomain(m, k) };
     }
 
     /**
-     * Access the domain value lower bound, based on <code>p</code>, used to
+     * Access the domain value lower bound, based on {@code p}, used to
      * bracket a PDF root.
      *
-     * @param p the desired probability for the critical value
-     * @return domain value lower bound, i.e. P(X &lt; <i>lower bound</i>) &lt;
-     *         <code>p</code>
+     * @param p Desired probability for the critical value.
+     * @return the domain value lower bound, i.e. {@code P(X < 'lower bound') < p}.
      */
     @Override
     protected int getDomainLowerBound(double p) {
@@ -123,12 +135,11 @@ public class HypergeometricDistributionI
     }
 
     /**
-     * Access the domain value upper bound, based on <code>p</code>, used to
+     * Access the domain value upper bound, based on {@code p}, used to
      * bracket a PDF root.
      *
-     * @param p the desired probability for the critical value
-     * @return domain value upper bound, i.e. P(X &lt; <i>upper bound</i>) &gt;
-     *         <code>p</code>
+     * @param p Desired probability for the critical value
+     * @return the domain value upper bound, i.e. {@code P(X < 'upper bound') > p}.
      */
     @Override
     protected int getDomainUpperBound(double p) {
@@ -139,9 +150,9 @@ public class HypergeometricDistributionI
      * Return the lowest domain value for the given hypergeometric distribution
      * parameters.
      *
-     * @param n the population size.
-     * @param m number of successes in the population.
-     * @param k the sample size.
+     * @param n Population size.
+     * @param m Number of successes in the population.
+     * @param k Sample size.
      * @return the lowest domain value of the hypergeometric distribution.
      */
     private int getLowerDomain(int n, int m, int k) {
@@ -149,27 +160,21 @@ public class HypergeometricDistributionI
     }
 
     /**
-     * Access the number of successes.
-     *
-     * @return the number of successes.
+     * {@inheritDoc}
      */
     public int getNumberOfSuccesses() {
         return numberOfSuccesses;
     }
 
     /**
-     * Access the population size.
-     *
-     * @return the population size.
+     * {@inheritDoc}
      */
     public int getPopulationSize() {
         return populationSize;
     }
 
     /**
-     * Access the sample size.
-     *
-     * @return the sample size.
+     * {@inheritDoc}
      */
     public int getSampleSize() {
         return sampleSize;
@@ -179,8 +184,8 @@ public class HypergeometricDistributionI
      * Return the highest domain value for the given hypergeometric distribution
      * parameters.
      *
-     * @param m number of successes in the population.
-     * @param k the sample size.
+     * @param m Number of successes in the population.
+     * @param k Sample size.
      * @return the highest domain value of the hypergeometric distribution.
      */
     private int getUpperDomain(int m, int k) {
@@ -188,9 +193,9 @@ public class HypergeometricDistributionI
     }
 
     /**
-     * For this distribution, X, this method returns P(X = x).
+     * For this distribution, {@code X}, this method returns {@code P(X = x)}.
      *
-     * @param x the value at which the PMF is evaluated.
+     * @param x Value at which the PMF is evaluated.
      * @return PMF for this distribution.
      */
     public double probability(int x) {
@@ -216,13 +221,13 @@ public class HypergeometricDistributionI
     }
 
     /**
-     * For the distribution, X, defined by the given hypergeometric distribution
-     * parameters, this method returns P(X = x).
+     * For this distribution, {@code X}, defined by the given hypergeometric
+     *  distribution parameters, this method returns {@code P(X = x)}.
      *
+     * @param x Value at which the PMF is evaluated.
      * @param n the population size.
      * @param m number of successes in the population.
      * @param k the sample size.
-     * @param x the value at which the PMF is evaluated.
      * @return PMF for the distribution.
      */
     private double probability(int n, int m, int k, int x) {
@@ -232,85 +237,10 @@ public class HypergeometricDistributionI
     }
 
     /**
-     * Modify the number of successes.
+     * For this distribution, {@code X}, this method returns {@code P(X >= x)}.
      *
-     * @param num the new number of successes.
-     * @throws IllegalArgumentException if <code>num</code> is negative.
-     * @deprecated as of 2.1 (class will become immutable in 3.0)
-     */
-    @Deprecated
-    public void setNumberOfSuccesses(int num) {
-        setNumberOfSuccessesInternal(num);
-    }
-    /**
-     * Modify the number of successes.
-     *
-     * @param num the new number of successes.
-     * @throws IllegalArgumentException if <code>num</code> is negative.
-     */
-    private void setNumberOfSuccessesInternal(int num) {
-        if (num < 0) {
-            throw MathRuntimeException.createIllegalArgumentException(
-                    LocalizedFormats.NEGATIVE_NUMBER_OF_SUCCESSES, num);
-        }
-        numberOfSuccesses = num;
-    }
-
-    /**
-     * Modify the population size.
-     *
-     * @param size the new population size.
-     * @throws IllegalArgumentException if <code>size</code> is not positive.
-     * @deprecated as of 2.1 (class will become immutable in 3.0)
-     */
-    @Deprecated
-    public void setPopulationSize(int size) {
-        setPopulationSizeInternal(size);
-    }
-    /**
-     * Modify the population size.
-     *
-     * @param size the new population size.
-     * @throws IllegalArgumentException if <code>size</code> is not positive.
-     */
-    private void setPopulationSizeInternal(int size) {
-        if (size <= 0) {
-            throw MathRuntimeException.createIllegalArgumentException(
-                    LocalizedFormats.NOT_POSITIVE_POPULATION_SIZE, size);
-        }
-        populationSize = size;
-    }
-
-    /**
-     * Modify the sample size.
-     *
-     * @param size the new sample size.
-     * @throws IllegalArgumentException if <code>size</code> is negative.
-     * @deprecated as of 2.1 (class will become immutable in 3.0)
-     */
-    @Deprecated
-    public void setSampleSize(int size) {
-        setSampleSizeInternal(size);
-    }
-    /**
-     * Modify the sample size.
-     *
-     * @param size the new sample size.
-     * @throws IllegalArgumentException if <code>size</code> is negative.
-     */
-    private void setSampleSizeInternal(int size) {
-        if (size < 0) {
-            throw MathRuntimeException.createIllegalArgumentException(
-                    LocalizedFormats.NOT_POSITIVE_SAMPLE_SIZE, size);
-        }
-        sampleSize = size;
-    }
-
-    /**
-     * For this distribution, X, this method returns P(X &ge; x).
-     *
-     * @param x the value at which the CDF is evaluated.
-     * @return upper tail CDF for this distribution.
+     * @param x Value at which the CDF is evaluated.
+     * @return the upper tail CDF for this distribution.
      * @since 1.1
      */
     public double upperCumulativeProbability(int x) {
@@ -322,28 +252,31 @@ public class HypergeometricDistributionI
         } else if (x > domain[1]) {
             ret = 0.0;
         } else {
-            ret = innerCumulativeProbability(domain[1], x, -1, populationSize, numberOfSuccesses, sampleSize);
+            ret = innerCumulativeProbability(domain[1], x, -1, populationSize,
+                                             numberOfSuccesses, sampleSize);
         }
 
         return ret;
     }
 
     /**
-     * For this distribution, X, this method returns P(x0 &le; X &le; x1). This
-     * probability is computed by summing the point probabilities for the values
-     * x0, x0 + 1, x0 + 2, ..., x1, in the order directed by dx.
-     *
-     * @param x0 the inclusive, lower bound
-     * @param x1 the inclusive, upper bound
-     * @param dx the direction of summation. 1 indicates summing from x0 to x1.
-     *            0 indicates summing from x1 to x0.
+     * For this distribution, {@code X}, this method returns
+     * {@code P(x0 <= X <= x1)}.
+     * This probability is computed by summing the point probabilities for the
+     * values {@code x0, x0 + 1, x0 + 2, ..., x1}, in the order directed by
+     * {@code dx}.
+     *
+     * @param x0 Inclusive lower bound.
+     * @param x1 Inclusive upper bound.
+     * @param dx Direction of summation (1 indicates summing from x0 to x1, and
+     * 0 indicates summing from x1 to x0).
      * @param n the population size.
      * @param m number of successes in the population.
      * @param k the sample size.
-     * @return P(x0 &le; X &le; x1).
+     * @return {@code P(x0 <= X <= x1)}.
      */
-    private double innerCumulativeProbability(int x0, int x1, int dx, int n,
-            int m, int k) {
+    private double innerCumulativeProbability(int x0, int x1, int dx,
+                                              int n, int m, int k) {
         double ret = probability(n, m, k, x0);
         while (x0 != x1) {
             x0 += dx;

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/IntegerDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/IntegerDistribution.java?rev=1003512&r1=1003511&r2=1003512&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/IntegerDistribution.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/IntegerDistribution.java Fri Oct  1 12:46:16 2010
@@ -25,60 +25,96 @@ import org.apache.commons.math.MathExcep
  */
 public interface IntegerDistribution extends DiscreteDistribution {
     /**
-     * For a random variable X whose values are distributed according
-     * to this distribution, this method returns P(X = x). In other words, this
-     * method represents the probability mass function for the distribution.
+     * 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 probability mass function for the
+     * distribution.
      *
-     * @param x the value at which the probability density function is evaluated.
-     * @return the value of the probability density function at x
+     * @param x Value at which the probability density function is evaluated.
+     * @return the value of the probability density function at {@code x}.
      */
     double probability(int x);
 
     /**
-     * For a random variable X whose values are distributed according
-     * to this distribution, this method returns P(X &le; x).  In other words,
-     * this method represents the probability distribution function, or PDF
-     * for the distribution.
+     * 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 probability distribution function, or
+     * PDF for the distribution.
      *
-     * @param x the value at which the PDF is evaluated.
+     * @param x Value at which the PDF is evaluated.
      * @return PDF for this distribution.
-     * @throws MathException if the cumulative probability can not be
-     *            computed due to convergence or other numerical errors.
+     * @throws MathException if the cumulative probability cannot be
+     * computed due to convergence or other numerical errors.
      */
     double cumulativeProbability(int x) throws MathException;
 
     /**
-     * For this distribution, X, this method returns P(x0 &le; X &le; x1).
+     * For this distribution, {@code X}, this method returns
+     * {@code P(x0 < X < x1)}.
+     *
      * @param x0 the inclusive, lower bound
      * @param x1 the inclusive, upper bound
      * @return the cumulative probability.
      * @throws MathException if the cumulative probability can not be
-     *            computed due to convergence or other numerical errors.
-     * @throws IllegalArgumentException if x0 > x1
+     * computed due to convergence or other numerical errors.
+     * @throws IllegalArgumentException if {@code x0 > x1}.
      */
     double cumulativeProbability(int x0, int x1) throws MathException;
 
     /**
-     * For this distribution, X, this method returns the largest x such that
-     * P(X &le; x) <= p.
-     * <p>
-     * Note that this definition implies: <ul>
-     * <li> If there is a minimum value, <code>m</code>, with positive
-     * probability under (the density of) X, then <code>m - 1</code> is
-     * returned by <code>inverseCumulativeProbability(0).</code>  If there is
-     * no such value <code>m,  Integer.MIN_VALUE</code> is
-     * returned.</li>
-     * <li> If there is a maximum value, <code>M</code>, such that
-     * P(X &le; M) =1, then <code>M</code> is returned by
-     * <code>inverseCumulativeProbability(1).</code>
-     * If there is no such value, <code>M, Integer.MAX_VALUE</code> is
-     * returned.</li></ul></p>
-     *
-     * @param p the cumulative probability.
-     * @return the largest x such that P(X &le; x) <= p
-     * @throws MathException if the inverse cumulative probability can not be
-     *            computed due to convergence or other numerical errors.
-     * @throws IllegalArgumentException if p is not between 0 and 1 (inclusive)
+     * For this distribution, {@code X}, this method returns the largest
+     * {@code x} such that {@code P(X < x) <= p}.
+     * <br/>
+     * Note that this definition implies:
+     * <ul>
+     *  <li> If there is a minimum value, {@code m}, with positive
+     *   probability under (the density of) {@code X}, then {@code m - 1} is
+     *   returned by {@code inverseCumulativeProbability(0).}  If there is
+     *   no such value {@code m},  {@code Integer.MIN_VALUE} is returned.
+     *  </li>
+     *  <li> If there is a maximum value, {@code M}, such that
+     *   {@code P(X < M) = 1}, then {@code M} is returned by
+     *   {@code inverseCumulativeProbability(1)}.
+     *   If there is no such value, {@code M}, {@code Integer.MAX_VALUE} is
+     *   returned.
+     *  </li>
+     * </ul>
+     *
+     * @param p Cumulative probability.
+     * @return the largest {@code x} such that {@code P(X < x) <= p}.
+     * @throws MathException if the inverse cumulative probability cannot be
+     * computed due to convergence or other numerical errors.
+     * @throws IllegalArgumentException if {@code p} is not between 0 and 1
+     * (inclusive).
      */
     int inverseCumulativeProbability(double p) throws MathException;
+
+    /**
+     * Reseed the random generator used to generate samples.
+     *
+     * @param seed New seed.
+     * @since 3.0
+     */
+    void reseedRandomGenerator(long seed);
+
+    /**
+     * Generate a random value sampled from this distribution.
+     *
+     * @return a random value.
+     * @throws MathException if an error occurs generating the random value.
+     * @since 3.0
+     */
+    int sample() throws MathException;
+
+    /**
+     * Generate a random sample from the distribution.
+     *
+     * @param sampleSize number of random values to generate.
+     * @return an array representing the random sample.
+     * @throws MathException if an error occurs generating the sample.
+     * @throws org.apache.commons.math.exception.NotStrictlyPositiveException
+     * if {@code sampleSize} is not positive.
+     * @since 3.0
+     */
+    int[] sample(int sampleSize) throws MathException;
 }

Modified: 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/NormalDistributionImpl.java?rev=1003512&r1=1003511&r2=1003512&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/NormalDistributionImpl.java Fri Oct  1 12:46:16 2010
@@ -35,7 +35,7 @@ import org.apache.commons.math.util.Fast
 public class NormalDistributionImpl extends AbstractContinuousDistribution
         implements NormalDistribution, Serializable {
     /**
-     * Default inverse cumulative probability accuracy
+     * Default inverse cumulative probability accuracy.
      * @since 2.1
      */
     public static final double DEFAULT_INVERSE_ABSOLUTE_ACCURACY = 1e-9;
@@ -44,9 +44,9 @@ public class NormalDistributionImpl exte
     /** &sqrt;(2 &pi;) */
     private static final double SQRT2PI = FastMath.sqrt(2 * FastMath.PI);
     /** Mean of this distribution. */
-    private double mean = 0;
+    private final double mean;
     /** Standard deviation of this distribution. */
-    private double standardDeviation = 1;
+    private final double standardDeviation;
     /** Inverse cumulative probability accuracy. */
     private final double solverAbsoluteAccuracy;
 

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=1003512&r1=1003511&r2=1003512&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 Fri Oct  1 12:46:16 2010
@@ -42,32 +42,14 @@ public interface PascalDistribution exte
     /**
      * Access the number of successes for this distribution.
      *
-     * @return the number of successes
+     * @return the number of successes.
      */
     int getNumberOfSuccesses();
 
     /**
      * Access the probability of success for this distribution.
      *
-     * @return the probability of success
+     * @return the probability of success.
      */
     double getProbabilityOfSuccess();
-
-    /**
-     * Change the number of successes for this distribution.
-     *
-     * @param successes the new number of successes
-     * @deprecated as of v2.1
-     */
-    @Deprecated
-    void setNumberOfSuccesses(int successes);
-
-    /**
-     * Change the probability of success for this distribution.
-     *
-     * @param p the new probability of success
-     * @deprecated as of v2.1
-     */
-    @Deprecated
-    void setProbabilityOfSuccess(double p);
 }

Modified: 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/PascalDistributionImpl.java?rev=1003512&r1=1003511&r2=1003512&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/PascalDistributionImpl.java Fri Oct  1 12:46:16 2010
@@ -19,7 +19,8 @@ package org.apache.commons.math.distribu
 import java.io.Serializable;
 
 import org.apache.commons.math.MathException;
-import org.apache.commons.math.MathRuntimeException;
+import org.apache.commons.math.exception.OutOfRangeException;
+import org.apache.commons.math.exception.NotPositiveException;
 import org.apache.commons.math.exception.util.LocalizedFormats;
 import org.apache.commons.math.special.Beta;
 import org.apache.commons.math.util.MathUtils;
@@ -32,101 +33,53 @@ import org.apache.commons.math.util.Fast
  */
 public class PascalDistributionImpl extends AbstractIntegerDistribution
     implements PascalDistribution, Serializable {
-
-    /** Serializable version identifier */
+    /** Serializable version identifier. */
     private static final long serialVersionUID = 6751309484392813623L;
-
-    /** The number of successes */
-    private int numberOfSuccesses;
-
-    /** The probability of success */
-    private double probabilityOfSuccess;
+    /** The number of successes. */
+    private final int numberOfSuccesses;
+    /** The probability of success. */
+    private final double probabilityOfSuccess;
 
     /**
      * Create a Pascal distribution with the given number of trials and
      * probability of success.
-     * @param r the number of successes
-     * @param p the probability of success
+     *
+     * @param r Number of successes.
+     * @param p Probability of success.
      */
     public PascalDistributionImpl(int r, double p) {
-        super();
-        setNumberOfSuccessesInternal(r);
-        setProbabilityOfSuccessInternal(p);
+        if (r < 0) {
+            throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SUCCESSES,
+                                           r);
+        }
+        if (p < 0 || p > 1) {
+            throw new OutOfRangeException(p, 0, 1);
+        }
+
+        numberOfSuccesses = r;
+        probabilityOfSuccess = p;
     }
 
     /**
-     * Access the number of successes for this distribution.
-     * @return the number of successes
+     * {@inheritDoc}
      */
     public int getNumberOfSuccesses() {
         return numberOfSuccesses;
     }
 
     /**
-     * Access the probability of success for this distribution.
-     * @return the probability of success
+     * {@inheritDoc}
      */
     public double getProbabilityOfSuccess() {
         return probabilityOfSuccess;
     }
 
     /**
-     * Change the number of successes for this distribution.
-     * @param successes the new number of successes
-     * @throws IllegalArgumentException if <code>successes</code> is not
-     *         positive.
-     * @deprecated as of 2.1 (class will become immutable in 3.0)
-     */
-    @Deprecated
-    public void setNumberOfSuccesses(int successes) {
-        setNumberOfSuccessesInternal(successes);
-    }
-    /**
-     * Change the number of successes for this distribution.
-     * @param successes the new number of successes
-     * @throws IllegalArgumentException if <code>successes</code> is not
-     *         positive.
-     */
-    private void setNumberOfSuccessesInternal(int successes) {
-        if (successes < 0) {
-            throw MathRuntimeException.createIllegalArgumentException(
-                  LocalizedFormats.NEGATIVE_NUMBER_OF_SUCCESSES,
-                  successes);
-        }
-        numberOfSuccesses = successes;
-    }
-
-    /**
-     * Change the probability of success for this distribution.
-     * @param p the new probability of success
-     * @throws IllegalArgumentException if <code>p</code> is not a valid
-     *         probability.
-     * @deprecated as of 2.1 (class will become immutable in 3.0)
-     */
-    @Deprecated
-    public void setProbabilityOfSuccess(double p) {
-        setProbabilityOfSuccessInternal(p);
-    }
-    /**
-     * Change the probability of success for this distribution.
-     * @param p the new probability of success
-     * @throws IllegalArgumentException if <code>p</code> is not a valid
-     *         probability.
-     */
-    private void setProbabilityOfSuccessInternal(double p) {
-        if (p < 0.0 || p > 1.0) {
-            throw MathRuntimeException.createIllegalArgumentException(
-                  LocalizedFormats.OUT_OF_RANGE_SIMPLE, p, 0.0, 1.0);
-        }
-        probabilityOfSuccess = p;
-    }
-
-    /**
-     * Access the domain value lower bound, based on <code>p</code>, used to
+     * Access the domain value lower bound, based on {@code p}, used to
      * bracket a PDF root.
-     * @param p the desired probability for the critical value
-     * @return domain value lower bound, i.e. P(X &lt; <i>lower bound</i>) &lt;
-     *         <code>p</code>
+     *
+     * @param p Desired probability for the critical value.
+     * @return the domain value lower bound, i.e. {@code P(X < 'lower bound') < p}.
      */
     @Override
     protected int getDomainLowerBound(double p) {
@@ -134,11 +87,11 @@ public class PascalDistributionImpl exte
     }
 
     /**
-     * Access the domain value upper bound, based on <code>p</code>, used to
+     * Access the domain value upper bound, based on {@code p}, used to
      * bracket a PDF root.
-     * @param p the desired probability for the critical value
-     * @return domain value upper bound, i.e. P(X &lt; <i>upper bound</i>) &gt;
-     *         <code>p</code>
+     *
+     * @param p Desired probability for the critical value
+     * @return the domain value upper bound, i.e. {@code P(X < 'upper bound') > p}.
      */
     @Override
     protected int getDomainUpperBound(double p) {
@@ -147,11 +100,12 @@ public class PascalDistributionImpl exte
     }
 
     /**
-     * For this distribution, X, this method returns P(X &le; x).
-     * @param x the value at which the PDF is evaluated
-     * @return PDF for this distribution
+     * 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.
      * @throws MathException if the cumulative probability can not be computed
-     *         due to convergence or other numerical errors
+     * due to convergence or other numerical errors.
      */
     @Override
     public double cumulativeProbability(int x) throws MathException {
@@ -166,9 +120,10 @@ public class PascalDistributionImpl exte
     }
 
     /**
-     * For this distribution, X, this method returns P(X = x).
-     * @param x the value at which the PMF is evaluated
-     * @return PMF for this distribution
+     * 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.
      */
     public double probability(int x) {
         double ret;
@@ -184,16 +139,15 @@ public class PascalDistributionImpl exte
     }
 
     /**
-     * For this distribution, X, this method returns the largest x, such that
-     * P(X &le; x) &le; <code>p</code>.
-     * <p>
-     * Returns <code>-1</code> for p=0 and <code>Integer.MAX_VALUE</code>
-     * for p=1.</p>
-     * @param p the desired probability
-     * @return the largest x such that P(X &le; x) <= p
+     * 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 MathException if the inverse cumulative probability can not be
-     *         computed due to convergence or other numerical errors.
-     * @throws IllegalArgumentException if p < 0 or p > 1
+     * computed due to convergence or other numerical errors.
+     * @throws OutOfRangeException if {@code p < 0} or {@code p > 1}.
      */
     @Override
     public int inverseCumulativeProbability(final double p)

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=1003512&r1=1003511&r2=1003512&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 Fri Oct  1 12:46:16 2010
@@ -31,50 +31,41 @@ import org.apache.commons.math.util.Fast
  * @version $Revision$ $Date$
  */
 public class PoissonDistributionImpl extends AbstractIntegerDistribution
-        implements PoissonDistribution, Serializable {
-
+    implements PoissonDistribution, Serializable {
     /**
      * Default maximum number of iterations for cumulative probability calculations.
      * @since 2.1
      */
     public static final int DEFAULT_MAX_ITERATIONS = 10000000;
-
     /**
      * Default convergence criterion.
      * @since 2.1
      */
-    public static final double DEFAULT_EPSILON = 1E-12;
-
-    /** Serializable version identifier */
+    public static final double DEFAULT_EPSILON = 1e-12;
+    /** Serializable version identifier. */
     private static final long serialVersionUID = -3349935121172596109L;
-
     /** Distribution used to compute normal approximation. */
-    private NormalDistribution normal;
-
-    /**
-     * Holds the Poisson mean for the distribution.
-     */
-    private double mean;
-
+    private final NormalDistribution normal;
+    /** Mean of the distribution. */
+    private final double mean;
     /**
      * Maximum number of iterations for cumulative probability.
      *
      * Cumulative probabilities are estimated using either Lanczos series approximation of
      * Gamma#regularizedGammaP or continued fraction approximation of Gamma#regularizedGammaQ.
      */
-    private int maxIterations = DEFAULT_MAX_ITERATIONS;
-
+    private final int maxIterations;
     /**
      * Convergence criterion for cumulative probability.
      */
-    private double epsilon = DEFAULT_EPSILON;
+    private final double epsilon;
 
     /**
      * Create a new Poisson distribution with the given the mean. The mean value
      * must be positive; otherwise an <code>IllegalArgument</code> is thrown.
      *
      * @param p the Poisson mean
-     * @throws IllegalArgumentException if p &le; 0
+     * @throws NotStrictlyPositiveException if {@code p <= 0}.
      */
     public PoissonDistributionImpl(double p) {
         this(p, DEFAULT_EPSILON, DEFAULT_MAX_ITERATIONS);
@@ -84,9 +75,10 @@ public class PoissonDistributionImpl ext
      * Create a new Poisson distribution with the given mean, convergence criterion
      * and maximum number of iterations.
      *
-     * @param p the Poisson mean
-     * @param epsilon the convergence criteria for cumulative probabilites
-     * @param maxIterations the maximum number of iterations for cumulative probabilites
+     * @param p Poisson mean.
+     * @param epsilon Convergence criterion for cumulative probabilities.
+     * @param maxIterations the maximum number of iterations for cumulative
+     * probabilities.
      * @since 2.1
      */
     public PoissonDistributionImpl(double p, double epsilon, int maxIterations) {
@@ -102,8 +94,8 @@ public class PoissonDistributionImpl ext
     /**
      * Create a new Poisson distribution with the given mean and convergence criterion.
      *
-     * @param p the Poisson mean
-     * @param epsilon the convergence criteria for cumulative probabilites
+     * @param p Poisson mean.
+     * @param epsilon Convergence criterion for cumulative probabilities.
      * @since 2.1
      */
     public PoissonDistributionImpl(double p, double epsilon) {
@@ -113,8 +105,8 @@ public class PoissonDistributionImpl ext
     /**
      * Create a new Poisson distribution with the given mean and maximum number of iterations.
      *
-     * @param p the Poisson mean
-     * @param maxIterations the maximum number of iterations for cumulative probabilites
+     * @param p Poisson mean.
+     * @param maxIterations Maximum number of iterations for cumulative probabilities.
      * @since 2.1
      */
     public PoissonDistributionImpl(double p, int maxIterations) {
@@ -122,20 +114,17 @@ public class PoissonDistributionImpl ext
     }
 
     /**
-     * Get the Poisson mean for the distribution.
-     *
-     * @return the Poisson mean for the distribution.
+     * {@inheritDoc}
      */
     public double getMean() {
         return mean;
     }
 
     /**
-     * The probability mass function P(X = x) for a Poisson distribution.
+     * The probability mass function {@code P(X = x)} for a Poisson distribution.
      *
-     * @param x the value at which the probability density function is
-     *            evaluated.
-     * @return the value of the probability mass function at x
+     * @param x Value at which the probability density function is evaluated.
+     * @return the value of the probability mass function at {@code x}.
      */
     public double probability(int x) {
         double ret;
@@ -152,13 +141,13 @@ public class PoissonDistributionImpl ext
     }
 
     /**
-     * The probability distribution function P(X <= x) for a Poisson
+     * The probability distribution function {@code P(X <= x)} for a Poisson
      * distribution.
      *
-     * @param x the value at which the PDF is evaluated.
-     * @return Poisson distribution function evaluated at x
-     * @throws MathException if the cumulative probability can not be computed
-     *             due to convergence or other numerical errors.
+     * @param x Value at which the PDF is evaluated.
+     * @return the Poisson distribution function evaluated at {@code x}.
+     * @throws MathException if the cumulative probability cannot be computed
+     * due to convergence or other numerical errors.
      */
     @Override
     public double cumulativeProbability(int x) throws MathException {
@@ -173,18 +162,16 @@ public class PoissonDistributionImpl ext
 
     /**
      * Calculates the Poisson distribution function using a normal
-     * approximation. The <code>N(mean, sqrt(mean))</code> distribution is used
+     * approximation. The {@code N(mean, sqrt(mean))} distribution is used
      * to approximate the Poisson distribution.
-     * <p>
-     * The computation uses "half-correction" -- evaluating the normal
-     * distribution function at <code>x + 0.5</code>
-     * </p>
+     * The computation uses "half-correction" (evaluating the normal
+     * distribution function at {@code x + 0.5}).
      *
-     * @param x the upper bound, inclusive
+     * @param x Upper bound, inclusive.
      * @return the distribution function value calculated using a normal
-     *         approximation
+     * approximation.
      * @throws MathException if an error occurs computing the normal
-     *             approximation
+     * approximation.
      */
     public double normalApproximateProbability(int x) throws MathException {
         // calculate the probability using half-correction
@@ -193,20 +180,25 @@ public class PoissonDistributionImpl ext
 
     /**
      * Generates a random value sampled from this distribution.
+     * <br/>
+     * <strong>Algorithm Description</strong>:
+     * <ul>
+     *  <li>For small means, uses simulation of a Poisson process
+     *   using Uniform deviates, as described
+     *   <a href="http://irmi.epfl.ch/cmos/Pmmi/interactive/rng7.htm"> here</a>.
+     *   The Poisson process (and hence value returned) is bounded by 1000 * mean.
+     *  </li>
+     *  <li>For large means, uses the rejection algorithm described in
+     *   <quote>
+     *    Devroye, Luc. (1981).<i>The Computer Generation of Poisson Random Variables</i>
+     *    <strong>Computing</strong> vol. 26 pp. 197-207.
+     *   </quote>
+     *  </li>
+     * </ul>
      *
-     * <p><strong>Algorithm Description</strong>:
-     * <ul><li> For small means, uses simulation of a Poisson process
-     * using Uniform deviates, as described
-     * <a href="http://irmi.epfl.ch/cmos/Pmmi/interactive/rng7.htm"> here.</a>
-     * The Poisson process (and hence value returned) is bounded by 1000 * mean.</li><
-     *
-     * <li> For large means, uses the rejection algorithm described in <br/>
-     * Devroye, Luc. (1981).<i>The Computer Generation of Poisson Random Variables</i>
-     * <strong>Computing</strong> vol. 26 pp. 197-207.</li></ul></p>
-     *
-     * @return random value
+     * @return a random value.
      * @since 2.2
-     * @throws MathException if an error occurs generating the random value
+     * @throws MathException if an error occurs generating the random value.
      */
     @Override
     public int sample() throws MathException {
@@ -214,12 +206,12 @@ public class PoissonDistributionImpl ext
     }
 
     /**
-     * Access the domain value lower bound, based on <code>p</code>, used to
+     * 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 the desired probability for the critical value
-     * @return domain lower bound
+     * @param p Desired probability for the critical value.
+     * @return the domain lower bound.
      */
     @Override
     protected int getDomainLowerBound(double p) {
@@ -227,12 +219,12 @@ public class PoissonDistributionImpl ext
     }
 
     /**
-     * Access the domain value upper bound, based on <code>p</code>, used to
+     * 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 the desired probability for the critical value
-     * @return domain upper bound
+     * @param p Desired probability for the critical value.
+     * @return the domain upper bound.
      */
     @Override
     protected int getDomainUpperBound(double p) {

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/TDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/TDistributionImpl.java?rev=1003512&r1=1003511&r2=1003512&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/TDistributionImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/TDistributionImpl.java Fri Oct  1 12:46:16 2010
@@ -42,7 +42,7 @@ public class TDistributionImpl
     /** Serializable version identifier */
     private static final long serialVersionUID = -5852615386664158222L;
     /** The degrees of freedom. */
-    private double degreesOfFreedom;
+    private final double degreesOfFreedom;
     /** Inverse cumulative probability accuracy. */
     private final double solverAbsoluteAccuracy;
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/WeibullDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/WeibullDistributionImpl.java?rev=1003512&r1=1003511&r2=1003512&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/WeibullDistributionImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/WeibullDistributionImpl.java Fri Oct  1 12:46:16 2010
@@ -32,18 +32,18 @@ import org.apache.commons.math.util.Fast
  * @version $Revision$ $Date$
  */
 public class WeibullDistributionImpl extends AbstractContinuousDistribution
-        implements WeibullDistribution, Serializable {
+    implements WeibullDistribution, Serializable {
     /**
-     * Default inverse cumulative probability accuracy
+     * Default inverse cumulative probability accuracy.
      * @since 2.1
      */
     public static final double DEFAULT_INVERSE_ABSOLUTE_ACCURACY = 1e-9;
-    /** Serializable version identifier */
+    /** Serializable version identifier. */
     private static final long serialVersionUID = 8589540077390120676L;
     /** The shape parameter. */
-    private double shape;
+    private final double shape;
     /** The scale parameter. */
-    private double scale;
+    private final double scale;
     /** Inverse cumulative probability accuracy. */
     private final double solverAbsoluteAccuracy;
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ZipfDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ZipfDistribution.java?rev=1003512&r1=1003511&r2=1003512&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ZipfDistribution.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ZipfDistribution.java Fri Oct  1 12:46:16 2010
@@ -30,7 +30,6 @@ package org.apache.commons.math.distribu
  * @version $Revision$ $Date$
  */
 public interface ZipfDistribution extends IntegerDistribution {
-
     /**
      * Get the number of elements (e.g. corpus size) for the distribution.
      *
@@ -39,33 +38,9 @@ public interface ZipfDistribution extend
     int getNumberOfElements();
 
     /**
-     * Set the number of elements (e.g. corpus size) for the distribution.
-     * The parameter value must be positive; otherwise an
-     * <code>IllegalArgumentException</code> is thrown.
-     *
-     * @param n the number of elements
-     * @throws IllegalArgumentException if n &le; 0
-     * @deprecated as of v2.1
-     */
-    @Deprecated
-    void setNumberOfElements(int n);
-
-    /**
      * Get the exponent characterising the distribution.
      *
      * @return the exponent
      */
     double getExponent();
-
-    /**
-     * Set the exponent characterising the distribution.
-     * The parameter value must be positive; otherwise an
-     * <code>IllegalArgumentException</code> is thrown.
-     *
-     * @param s the exponent
-     * @throws IllegalArgumentException if s &le; 0.0
-     * @deprecated as of v2.1
-     */
-    @Deprecated
-    void setExponent(double s);
 }



Mime
View raw message