commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r920852 - in /commons/proper/math/trunk: ./ src/main/java/org/apache/commons/math/distribution/
Date Tue, 09 Mar 2010 12:53:45 GMT
Author: erans
Date: Tue Mar  9 12:53:44 2010
New Revision: 920852

URL: http://svn.apache.org/viewvc?rev=920852&view=rev
Log:
Issues
  https://issues.apache.org/jira/browse/MATH-348
  https://issues.apache.org/jira/browse/MATH-349


Modified:
    commons/proper/math/trunk/pom.xml
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BetaDistribution.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/CauchyDistribution.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/ChiSquaredDistribution.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/ExponentialDistribution.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/FDistribution.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/GammaDistribution.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/NormalDistribution.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/PoissonDistribution.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/TDistribution.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/WeibullDistribution.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

Modified: commons/proper/math/trunk/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/pom.xml?rev=920852&r1=920851&r2=920852&view=diff
==============================================================================
--- commons/proper/math/trunk/pom.xml (original)
+++ commons/proper/math/trunk/pom.xml Tue Mar  9 12:53:44 2010
@@ -102,6 +102,11 @@
       <id>brentworden</id>
       <email>brentworden at apache dot org</email>
     </developer>
+    <developer>
+      <name>Gilles Sadowski</name>
+      <id>erans</id>
+      <email>erans at apache dot org</email>
+    </developer>
   </developers>
   <contributors>
     <contributor>
@@ -192,9 +197,6 @@
       <name>Matthew Rowles</name>
     </contributor>
     <contributor>
-      <name>Gilles Sadowski</name>
-    </contributor>
-    <contributor>
       <name>Joni Salonen</name>
     </contributor>
     <contributor>

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BetaDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BetaDistribution.java?rev=920852&r1=920851&r2=920852&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BetaDistribution.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BetaDistribution.java Tue Mar  9 12:53:44 2010
@@ -27,10 +27,12 @@ import org.apache.commons.math.MathExcep
  */
 public interface BetaDistribution extends ContinuousDistribution, HasDensity<Double> {
     /**
-      * Modify the shape parameter, alpha.
-      * @param alpha the new shape parameter.
-      */
-     void setAlpha(double alpha);
+     * Modify the shape parameter, alpha.
+     * @param alpha the new shape parameter.
+     * @deprecated as of 2.1
+     */
+    @Deprecated
+    void setAlpha(double alpha);
 
      /**
       * Access the shape parameter, alpha
@@ -41,7 +43,9 @@ public interface BetaDistribution extend
      /**
       * Modify the shape parameter, beta.
       * @param beta the new scale parameter.
+      * @deprecated as of 2.1
       */
+     @Deprecated
      void setBeta(double beta);
 
      /**

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=920852&r1=920851&r2=920852&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 Tue Mar  9 12:53:44 2010
@@ -60,7 +60,10 @@ public class BetaDistributionImpl
         z = Double.NaN;
     }
 
-    /** {@inheritDoc} */
+    /** {@inheritDoc}
+     * @deprecated as of 2.1 (class will become immutable in 3.0)
+     */
+    @Deprecated
     public void setAlpha(double alpha) {
         this.alpha = alpha;
         z = Double.NaN;
@@ -71,7 +74,10 @@ public class BetaDistributionImpl
         return alpha;
     }
 
-    /** {@inheritDoc} */
+    /** {@inheritDoc}
+     * @deprecated as of 2.1 (class will become immutable in 3.0)
+     */
+    @Deprecated
     public void setBeta(double beta) {
         this.beta = beta;
         z = Double.NaN;

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=920852&r1=920851&r2=920852&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 Tue Mar  9 12:53:44 2010
@@ -45,12 +45,16 @@ public interface BinomialDistribution ex
     /**
      * 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=920852&r1=920851&r2=920852&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 Tue Mar  9 12:53:44 2010
@@ -48,8 +48,8 @@ public class BinomialDistributionImpl ex
      */
     public BinomialDistributionImpl(int trials, double p) {
         super();
-        setNumberOfTrials(trials);
-        setProbabilityOfSuccess(p);
+        setNumberOfTrialsInternal(trials);
+        setProbabilityOfSuccessInternal(p);
     }
 
     /**
@@ -76,8 +76,20 @@ public class BinomialDistributionImpl ex
      * @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(
                     "number of trials must be non-negative ({0})", trials);
@@ -91,8 +103,20 @@ public class BinomialDistributionImpl ex
      * @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(
                     "{0} out of [{1}, {2}] range", p, 0.0, 1.0);
@@ -123,7 +147,7 @@ public class BinomialDistributionImpl ex
      */
     @Override
     protected int getDomainUpperBound(double p) {
-        return getNumberOfTrials();
+        return numberOfTrials;
     }
 
     /**
@@ -139,11 +163,11 @@ public class BinomialDistributionImpl ex
         double ret;
         if (x < 0) {
             ret = 0.0;
-        } else if (x >= getNumberOfTrials()) {
+        } else if (x >= numberOfTrials) {
             ret = 1.0;
         } else {
             ret = 1.0 - Beta.regularizedBeta(getProbabilityOfSuccess(),
-                    x + 1.0, getNumberOfTrials() - x);
+                    x + 1.0, numberOfTrials - x);
         }
         return ret;
     }
@@ -156,7 +180,7 @@ public class BinomialDistributionImpl ex
      */
     public double probability(int x) {
         double ret;
-        if (x < 0 || x > getNumberOfTrials()) {
+        if (x < 0 || x > numberOfTrials) {
             ret = 0.0;
         } else {
             ret = Math.exp(SaddlePointExpansion.logBinomialProbability(x,

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/CauchyDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/CauchyDistribution.java?rev=920852&r1=920851&r2=920852&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/CauchyDistribution.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/CauchyDistribution.java Tue Mar  9 12:53:44 2010
@@ -48,12 +48,16 @@ public interface CauchyDistribution exte
     /**
      * Modify the median.
      * @param median for this distribution
+     * @deprecated as of v2.1
      */
+    @Deprecated
     void setMedian(double median);
 
     /**
      * Modify the scale parameter.
      * @param s scale parameter for this distribution
+     * @deprecated as of v2.1
      */
+    @Deprecated
     void setScale(double s);
 }

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=920852&r1=920851&r2=920852&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 Tue Mar  9 12:53:44 2010
@@ -55,8 +55,8 @@ public class CauchyDistributionImpl exte
      */
     public CauchyDistributionImpl(double median, double s){
         super();
-        setMedian(median);
-        setScale(s);
+        setMedianInternal(median);
+        setScaleInternal(s);
     }
 
     /**
@@ -115,8 +115,17 @@ public class CauchyDistributionImpl exte
     /**
      * Modify the median.
      * @param median for this distribution
+     * @deprecated as of 2.1 (class will become immutable in 3.0)
      */
+    @Deprecated
     public void setMedian(double median) {
+        setMedianInternal(median);
+    }
+    /**
+     * Modify the median.
+     * @param median for this distribution
+     */
+    private void setMedianInternal(double median) {
         this.median = median;
     }
 
@@ -124,8 +133,18 @@ public class CauchyDistributionImpl exte
      * Modify the scale parameter.
      * @param s scale parameter for this distribution
      * @throws IllegalArgumentException if <code>sd</code> is not positive.
+     * @deprecated as of 2.1 (class will become immutable in 3.0)
      */
+    @Deprecated
     public void setScale(double s) {
+        setScaleInternal(s);
+    }
+    /**
+     * Modify the scale parameter.
+     * @param s scale parameter for this distribution
+     * @throws IllegalArgumentException if <code>sd</code> is not positive.
+     */
+    private void setScaleInternal(double s) {
         if (s <= 0.0) {
             throw MathRuntimeException.createIllegalArgumentException(
                   "scale must be positive ({0})", s);
@@ -149,7 +168,7 @@ public class CauchyDistributionImpl exte
         if (p < .5) {
             ret = -Double.MAX_VALUE;
         } else {
-            ret = getMedian();
+            ret = median;
         }
 
         return ret;
@@ -169,7 +188,7 @@ public class CauchyDistributionImpl exte
         double ret;
 
         if (p < .5) {
-            ret = getMedian();
+            ret = median;
         } else {
             ret = Double.MAX_VALUE;
         }
@@ -190,11 +209,11 @@ public class CauchyDistributionImpl exte
         double ret;
 
         if (p < .5) {
-            ret = getMedian() - getScale();
+            ret = median - scale;
         } else if (p > .5) {
-            ret = getMedian() + getScale();
+            ret = median + scale;
         } else {
-            ret = getMedian();
+            ret = median;
         }
 
         return ret;

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistribution.java?rev=920852&r1=920851&r2=920852&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistribution.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistribution.java Tue Mar  9 12:53:44 2010
@@ -33,7 +33,9 @@ public interface ChiSquaredDistribution 
     /**
      * Modify the degrees of freedom.
      * @param degreesOfFreedom the new degrees of freedom.
+     * @deprecated as of v2.1
      */
+    @Deprecated
     void setDegreesOfFreedom(double degreesOfFreedom);
 
     /**

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=920852&r1=920851&r2=920852&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 Tue Mar  9 12:53:44 2010
@@ -48,19 +48,31 @@ public class ChiSquaredDistributionImpl
      * @param df degrees of freedom.
      * @param g the underlying gamma distribution used to compute probabilities.
      * @since 1.2
+     * @deprecated as of 2.1 (to avoid possibly inconsistent state, the
+     * "GammaDistribution" will be instantiated internally)
      */
+    @Deprecated
     public ChiSquaredDistributionImpl(double df, GammaDistribution g) {
         super();
-        setGamma(g);
-        setDegreesOfFreedom(df);
+        setGammaInternal(g);
+        setDegreesOfFreedomInternal(df);
     }
 
     /**
      * Modify the degrees of freedom.
      * @param degreesOfFreedom the new degrees of freedom.
+     * @deprecated as of 2.1 (class will become immutable in 3.0)
      */
+    @Deprecated
     public void setDegreesOfFreedom(double degreesOfFreedom) {
-        getGamma().setAlpha(degreesOfFreedom / 2.0);
+        setDegreesOfFreedomInternal(degreesOfFreedom);
+    }
+    /**
+     * Modify the degrees of freedom.
+     * @param degreesOfFreedom the new degrees of freedom.
+     */
+    private void setDegreesOfFreedomInternal(double degreesOfFreedom) {
+        gamma.setAlpha(degreesOfFreedom / 2.0);
     }
 
     /**
@@ -68,7 +80,7 @@ public class ChiSquaredDistributionImpl
      * @return the degrees of freedom.
      */
     public double getDegreesOfFreedom() {
-        return getGamma().getAlpha() * 2.0;
+        return gamma.getAlpha() * 2.0;
     }
 
     /**
@@ -89,7 +101,7 @@ public class ChiSquaredDistributionImpl
      *            computed due to convergence or other numerical errors.
      */
     public double cumulativeProbability(double x) throws MathException {
-        return getGamma().cumulativeProbability(x);
+        return gamma.cumulativeProbability(x);
     }
 
     /**
@@ -128,7 +140,7 @@ public class ChiSquaredDistributionImpl
      */
     @Override
     protected double getDomainLowerBound(double p) {
-        return Double.MIN_VALUE * getGamma().getBeta();
+        return Double.MIN_VALUE * gamma.getBeta();
     }
 
     /**
@@ -189,8 +201,19 @@ public class ChiSquaredDistributionImpl
      * insuring the gamma distribution has the proper parameter settings.
      * @param g the new distribution.
      * @since 1.2 made public
+     * @deprecated as of 2.1 (class will become immutable in 3.0)
      */
+    @Deprecated
     public void setGamma(GammaDistribution g) {
+        setGammaInternal(g);
+    }
+    /**
+     * Modify the underlying gamma distribution.  The caller is responsible for
+     * insuring the gamma distribution has the proper parameter settings.
+     * @param g the new distribution.
+     * @since 1.2 made public
+     */
+    private void setGammaInternal(GammaDistribution g) {
         this.gamma = g;
 
     }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ExponentialDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ExponentialDistribution.java?rev=920852&r1=920851&r2=920852&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ExponentialDistribution.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ExponentialDistribution.java Tue Mar  9 12:53:44 2010
@@ -33,7 +33,9 @@ public interface ExponentialDistribution
     /**
      * Modify the mean.
      * @param mean the new mean.
+     * @deprecated as of v2.1
      */
+    @Deprecated
     void setMean(double mean);
 
     /**

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=920852&r1=920851&r2=920852&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 Tue Mar  9 12:53:44 2010
@@ -41,15 +41,25 @@ public class ExponentialDistributionImpl
      */
     public ExponentialDistributionImpl(double mean) {
         super();
-        setMean(mean);
+        setMeanInternal(mean);
     }
 
     /**
      * Modify the mean.
      * @param mean the new mean.
      * @throws IllegalArgumentException if <code>mean</code> is not positive.
+     * @deprecated as of 2.1 (class will become immutable in 3.0)
      */
+    @Deprecated
     public void setMean(double mean) {
+        setMeanInternal(mean);
+    }
+    /**
+     * Modify the mean.
+     * @param mean the new mean.
+     * @throws IllegalArgumentException if <code>mean</code> is not positive.
+     */
+    private void setMeanInternal(double mean) {
         if (mean <= 0.0) {
             throw MathRuntimeException.createIllegalArgumentException(
                   "mean must be positive ({0})", mean);
@@ -75,7 +85,7 @@ public class ExponentialDistributionImpl
         if (x < 0) {
             return 0;
         }
-        return Math.exp(-x / getMean()) / getMean();
+        return Math.exp(-x / mean) / mean;
     }
 
     /**
@@ -98,7 +108,7 @@ public class ExponentialDistributionImpl
         if (x <= 0.0) {
             ret = 0.0;
         } else {
-            ret = 1.0 - Math.exp(-x / getMean());
+            ret = 1.0 - Math.exp(-x / mean);
         }
         return ret;
     }
@@ -125,7 +135,7 @@ public class ExponentialDistributionImpl
         } else if (p == 1.0) {
             ret = Double.POSITIVE_INFINITY;
         } else {
-            ret = -getMean() * Math.log(1.0 - p);
+            ret = -mean * Math.log(1.0 - p);
         }
 
         return ret;
@@ -159,7 +169,7 @@ public class ExponentialDistributionImpl
 
         if (p < .5) {
             // use mean
-            return getMean();
+            return mean;
         } else {
             // use max
             return Double.MAX_VALUE;
@@ -181,10 +191,10 @@ public class ExponentialDistributionImpl
         // Exponential is skewed to the left, therefore, P(X < &mu;) > .5
         if (p < .5) {
             // use 1/2 mean
-            return getMean() * .5;
+            return mean * .5;
         } else {
             // use mean
-            return getMean();
+            return mean;
         }
     }
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/FDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/FDistribution.java?rev=920852&r1=920851&r2=920852&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/FDistribution.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/FDistribution.java Tue Mar  9 12:53:44 2010
@@ -33,7 +33,9 @@ public interface FDistribution extends C
     /**
      * Modify the numerator degrees of freedom.
      * @param degreesOfFreedom the new numerator degrees of freedom.
+     * @deprecated as of v2.1
      */
+    @Deprecated
     void setNumeratorDegreesOfFreedom(double degreesOfFreedom);
 
     /**
@@ -45,7 +47,9 @@ public interface FDistribution extends C
     /**
      * Modify the denominator degrees of freedom.
      * @param degreesOfFreedom the new denominator degrees of freedom.
+     * @deprecated as of v2.1
      */
+    @Deprecated
     void setDenominatorDegreesOfFreedom(double degreesOfFreedom);
 
     /**

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=920852&r1=920851&r2=920852&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 Tue Mar  9 12:53:44 2010
@@ -51,10 +51,10 @@ public class FDistributionImpl
      * @param denominatorDegreesOfFreedom the denominator degrees of freedom.
      */
     public FDistributionImpl(double numeratorDegreesOfFreedom,
-            double denominatorDegreesOfFreedom) {
+                             double denominatorDegreesOfFreedom) {
         super();
-        setNumeratorDegreesOfFreedom(numeratorDegreesOfFreedom);
-        setDenominatorDegreesOfFreedom(denominatorDegreesOfFreedom);
+        setNumeratorDegreesOfFreedomInternal(numeratorDegreesOfFreedom);
+        setDenominatorDegreesOfFreedomInternal(denominatorDegreesOfFreedom);
     }
 
     /**
@@ -77,8 +77,8 @@ public class FDistributionImpl
         if (x <= 0.0) {
             ret = 0.0;
         } else {
-            double n = getNumeratorDegreesOfFreedom();
-            double m = getDenominatorDegreesOfFreedom();
+            double n = numeratorDegreesOfFreedom;
+            double m = denominatorDegreesOfFreedom;
 
             ret = Beta.regularizedBeta((n * x) / (m + n * x),
                 0.5 * n,
@@ -151,7 +151,7 @@ public class FDistributionImpl
     @Override
     protected double getInitialDomain(double p) {
         double ret = 1.0;
-        double d = getDenominatorDegreesOfFreedom();
+        double d = denominatorDegreesOfFreedom;
         if (d > 2.0) {
             // use mean
             ret = d / (d - 2.0);
@@ -164,8 +164,20 @@ public class FDistributionImpl
      * @param degreesOfFreedom the new numerator degrees of freedom.
      * @throws IllegalArgumentException if <code>degreesOfFreedom</code> is not
      *         positive.
+     * @deprecated as of 2.1 (class will become immutable in 3.0)
      */
+    @Deprecated
     public void setNumeratorDegreesOfFreedom(double degreesOfFreedom) {
+        setNumeratorDegreesOfFreedomInternal(degreesOfFreedom);
+    }
+
+    /**
+     * Modify the numerator degrees of freedom.
+     * @param degreesOfFreedom the new numerator degrees of freedom.
+     * @throws IllegalArgumentException if <code>degreesOfFreedom</code> is not
+     *         positive.
+     */
+    private void setNumeratorDegreesOfFreedomInternal(double degreesOfFreedom) {
         if (degreesOfFreedom <= 0.0) {
             throw MathRuntimeException.createIllegalArgumentException(
                   NON_POSITIVE_DEGREES_OF_FREEDOM_MESSAGE, degreesOfFreedom);
@@ -186,8 +198,20 @@ public class FDistributionImpl
      * @param degreesOfFreedom the new denominator degrees of freedom.
      * @throws IllegalArgumentException if <code>degreesOfFreedom</code> is not
      *         positive.
+     * @deprecated as of 2.1 (class will become immutable in 3.0)
      */
+    @Deprecated
     public void setDenominatorDegreesOfFreedom(double degreesOfFreedom) {
+        setDenominatorDegreesOfFreedomInternal(degreesOfFreedom);
+    }
+
+    /**
+     * Modify the denominator degrees of freedom.
+     * @param degreesOfFreedom the new denominator degrees of freedom.
+     * @throws IllegalArgumentException if <code>degreesOfFreedom</code> is not
+     *         positive.
+     */
+    private void setDenominatorDegreesOfFreedomInternal(double degreesOfFreedom) {
         if (degreesOfFreedom <= 0.0) {
             throw MathRuntimeException.createIllegalArgumentException(
                   NON_POSITIVE_DEGREES_OF_FREEDOM_MESSAGE, degreesOfFreedom);

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/GammaDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/GammaDistribution.java?rev=920852&r1=920851&r2=920852&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/GammaDistribution.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/GammaDistribution.java Tue Mar  9 12:53:44 2010
@@ -33,7 +33,9 @@ public interface GammaDistribution exten
     /**
      * Modify the shape parameter, alpha.
      * @param alpha the new shape parameter.
+     * @deprecated as of v2.1
      */
+    @Deprecated
     void setAlpha(double alpha);
 
     /**
@@ -45,7 +47,9 @@ public interface GammaDistribution exten
     /**
      * Modify the scale parameter, beta.
      * @param beta the new scale parameter.
+     * @deprecated as of v2.1
      */
+    @Deprecated
     void setBeta(double beta);
 
     /**

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=920852&r1=920851&r2=920852&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 Tue Mar  9 12:53:44 2010
@@ -46,8 +46,8 @@ public class GammaDistributionImpl exten
      */
     public GammaDistributionImpl(double alpha, double beta) {
         super();
-        setAlpha(alpha);
-        setBeta(beta);
+        setAlphaInternal(alpha);
+        setBetaInternal(beta);
     }
 
     /**
@@ -73,7 +73,7 @@ public class GammaDistributionImpl exten
         if (x <= 0.0) {
             ret = 0.0;
         } else {
-            ret = Gamma.regularizedGammaP(getAlpha(), x / getBeta());
+            ret = Gamma.regularizedGammaP(alpha, x / beta);
         }
 
         return ret;
@@ -108,8 +108,19 @@ public class GammaDistributionImpl exten
      * Modify the shape parameter, alpha.
      * @param alpha the new shape parameter.
      * @throws IllegalArgumentException if <code>alpha</code> is not positive.
+     * @deprecated as of 2.1 (class will become immutable in 3.0)
      */
+    @Deprecated
     public void setAlpha(double alpha) {
+        setAlphaInternal(alpha);
+    }
+
+    /**
+     * Modify the shape parameter, alpha.
+     * @param alpha the new shape parameter.
+     * @throws IllegalArgumentException if <code>alpha</code> is not positive.
+     */
+    private void setAlphaInternal(double alpha) {
         if (alpha <= 0.0) {
             throw MathRuntimeException.createIllegalArgumentException(
                   "alpha must be positive ({0})",
@@ -130,8 +141,19 @@ public class GammaDistributionImpl exten
      * Modify the scale parameter, beta.
      * @param beta the new scale parameter.
      * @throws IllegalArgumentException if <code>beta</code> is not positive.
+     * @deprecated as of 2.1 (class will become immutable in 3.0)
      */
+    @Deprecated
     public void setBeta(double beta) {
+        setBetaInternal(beta);
+    }
+
+    /**
+     * Modify the scale parameter, beta.
+     * @param beta the new scale parameter.
+     * @throws IllegalArgumentException if <code>beta</code> is not positive.
+     */
+    private void setBetaInternal(double beta) {
         if (beta <= 0.0) {
             throw MathRuntimeException.createIllegalArgumentException(
                   "beta must be positive ({0})",
@@ -156,7 +178,7 @@ public class GammaDistributionImpl exten
      */
     public double density(Double x) {
         if (x < 0) return 0;
-        return Math.pow(x / getBeta(), getAlpha() - 1) / getBeta() * Math.exp(-x / getBeta()) / Math.exp(Gamma.logGamma(getAlpha()));
+        return Math.pow(x / beta, alpha - 1) / beta * Math.exp(-x / beta) / Math.exp(Gamma.logGamma(alpha));
     }
 
     /**
@@ -193,7 +215,7 @@ public class GammaDistributionImpl exten
 
         if (p < .5) {
             // use mean
-            ret = getAlpha() * getBeta();
+            ret = alpha * beta;
         } else {
             // use max value
             ret = Double.MAX_VALUE;
@@ -219,10 +241,10 @@ public class GammaDistributionImpl exten
 
         if (p < .5) {
             // use 1/2 mean
-            ret = getAlpha() * getBeta() * .5;
+            ret = alpha * beta * .5;
         } else {
             // use mean
-            ret = getAlpha() * getBeta();
+            ret = alpha * beta;
         }
 
         return ret;

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=920852&r1=920851&r2=920852&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 Tue Mar  9 12:53:44 2010
@@ -53,19 +53,24 @@ public interface HypergeometricDistribut
     /**
      * 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=920852&r1=920851&r2=920852&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 Tue Mar  9 12:53:44 2010
@@ -65,9 +65,10 @@ public class HypergeometricDistributionI
                             "sample size ({0}) must be less than or equal to population size ({1})",
                             sampleSize, populationSize);
         }
-        setPopulationSize(populationSize);
-        setSampleSize(sampleSize);
-        setNumberOfSuccesses(numberOfSuccesses);
+
+        setPopulationSizeInternal(populationSize);
+        setSampleSizeInternal(sampleSize);
+        setNumberOfSuccessesInternal(numberOfSuccesses);
     }
 
     /**
@@ -80,17 +81,14 @@ public class HypergeometricDistributionI
     public double cumulativeProbability(int x) {
         double ret;
 
-        int n = getPopulationSize();
-        int m = getNumberOfSuccesses();
-        int k = getSampleSize();
-
-        int[] domain = getDomain(n, m, k);
+        int[] domain = getDomain(populationSize, numberOfSuccesses, sampleSize);
         if (x < domain[0]) {
             ret = 0.0;
         } else if (x >= domain[1]) {
             ret = 1.0;
         } else {
-            ret = innerCumulativeProbability(domain[0], x, 1, n, m, k);
+            ret = innerCumulativeProbability(domain[0], x, 1, populationSize,
+                                             numberOfSuccesses, sampleSize);
         }
 
         return ret;
@@ -119,8 +117,7 @@ public class HypergeometricDistributionI
      */
     @Override
     protected int getDomainLowerBound(double p) {
-        return getLowerDomain(getPopulationSize(), getNumberOfSuccesses(),
-                getSampleSize());
+        return getLowerDomain(populationSize, numberOfSuccesses, sampleSize);
     }
 
     /**
@@ -133,7 +130,7 @@ public class HypergeometricDistributionI
      */
     @Override
     protected int getDomainUpperBound(double p) {
-        return getUpperDomain(getSampleSize(), getNumberOfSuccesses());
+        return getUpperDomain(sampleSize, numberOfSuccesses);
     }
 
     /**
@@ -197,23 +194,19 @@ public class HypergeometricDistributionI
     public double probability(int x) {
         double ret;
 
-        int m = getPopulationSize();
-        int s = getNumberOfSuccesses();
-        int f = m - s;
-        int k = getSampleSize();
-
-        int[] domain = getDomain(m, s, k);
+        int[] domain = getDomain(populationSize, numberOfSuccesses, sampleSize);
         if (x < domain[0] || x > domain[1]) {
             ret = 0.0;
         } else {
-            double p = (double) sampleSize / (double) m;
-            double q = (double) (m - sampleSize) / (double) m;
+            double p = (double) sampleSize / (double) populationSize;
+            double q = (double) (populationSize - sampleSize) / (double) populationSize;
             double p1 = SaddlePointExpansion.logBinomialProbability(x,
                     numberOfSuccesses, p, q);
             double p2 =
-                SaddlePointExpansion.logBinomialProbability(sampleSize - x, f, p, q);
+                SaddlePointExpansion.logBinomialProbability(sampleSize - x,
+                    populationSize - numberOfSuccesses, p, q);
             double p3 =
-                SaddlePointExpansion.logBinomialProbability(sampleSize, m, p, q);
+                SaddlePointExpansion.logBinomialProbability(sampleSize, populationSize, p, q);
             ret = Math.exp(p1 + p2 - p3);
         }
 
@@ -241,8 +234,19 @@ public class HypergeometricDistributionI
      *
      * @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(
                     "number of successes must be non-negative ({0})", num);
@@ -255,8 +259,19 @@ public class HypergeometricDistributionI
      *
      * @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(
                     "population size must be positive ({0})", size);
@@ -269,8 +284,19 @@ public class HypergeometricDistributionI
      *
      * @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(
                     "sample size must be positive ({0})", size);
@@ -288,17 +314,13 @@ public class HypergeometricDistributionI
     public double upperCumulativeProbability(int x) {
         double ret;
 
-        int n = getPopulationSize();
-        int m = getNumberOfSuccesses();
-        int k = getSampleSize();
-
-        int[] domain = getDomain(n, m, k);
+        final int[] domain = getDomain(populationSize, numberOfSuccesses, sampleSize);
         if (x < domain[0]) {
             ret = 1.0;
         } else if (x > domain[1]) {
             ret = 0.0;
         } else {
-            ret = innerCumulativeProbability(domain[1], x, -1, n, m, k);
+            ret = innerCumulativeProbability(domain[1], x, -1, populationSize, numberOfSuccesses, sampleSize);
         }
 
         return ret;

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/NormalDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/NormalDistribution.java?rev=920852&r1=920851&r2=920852&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/NormalDistribution.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/NormalDistribution.java Tue Mar  9 12:53:44 2010
@@ -39,7 +39,9 @@ public interface NormalDistribution exte
     /**
      * Modify the mean.
      * @param mean for this distribution
+     * @deprecated as of v2.1
      */
+    @Deprecated
     void setMean(double mean);
     /**
      * Access the standard deviation.
@@ -49,7 +51,9 @@ public interface NormalDistribution exte
     /**
      * Modify the standard deviation.
      * @param sd standard deviation for this distribution
+     * @deprecated as of v2.1
      */
+    @Deprecated
     void setStandardDeviation(double sd);
 
     /**

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=920852&r1=920851&r2=920852&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 Tue Mar  9 12:53:44 2010
@@ -70,8 +70,8 @@ public class NormalDistributionImpl exte
      */
     public NormalDistributionImpl(double mean, double sd, double inverseCumAccuracy) {
         super();
-        this.mean = mean;
-        this.standardDeviation = sd;
+        setMeanInternal(mean);
+        setStandardDeviationInternal(sd);
         solverAbsoluteAccuracy = inverseCumAccuracy;
     }
 
@@ -94,8 +94,17 @@ public class NormalDistributionImpl exte
     /**
      * Modify the mean.
      * @param mean for this distribution
+     * @deprecated as of 2.1 (class will become immutable in 3.0)
      */
+    @Deprecated
     public void setMean(double mean) {
+        setMeanInternal(mean);
+    }
+    /**
+     * Modify the mean.
+     * @param mean for this distribution
+     */
+    private void setMeanInternal(double mean) {
         this.mean = mean;
     }
 
@@ -111,8 +120,18 @@ public class NormalDistributionImpl exte
      * Modify the standard deviation.
      * @param sd standard deviation for this distribution
      * @throws IllegalArgumentException if <code>sd</code> is not positive.
+     * @deprecated as of 2.1 (class will become immutable in 3.0)
      */
+    @Deprecated
     public void setStandardDeviation(double sd) {
+        setStandardDeviationInternal(sd);
+    }
+    /**
+     * Modify the standard deviation.
+     * @param sd standard deviation for this distribution
+     * @throws IllegalArgumentException if <code>sd</code> is not positive.
+     */
+    private void setStandardDeviationInternal(double sd) {
         if (sd <= 0.0) {
             throw MathRuntimeException.createIllegalArgumentException(
                   "standard deviation must be positive ({0})",
@@ -128,8 +147,8 @@ public class NormalDistributionImpl exte
      * @return The pdf at point x.
      */
     public double density(Double x) {
-        double x0 = x - getMean();
-        return Math.exp(-x0 * x0 / (2 * getStandardDeviation() * getStandardDeviation())) / (getStandardDeviation() * SQRT2PI);
+        double x0 = x - mean;
+        return Math.exp(-x0 * x0 / (2 * standardDeviation * standardDeviation)) / (standardDeviation * SQRT2PI);
     }
 
     /**
@@ -208,7 +227,7 @@ public class NormalDistributionImpl exte
         if (p < .5) {
             ret = -Double.MAX_VALUE;
         } else {
-            ret = getMean();
+            ret = mean;
         }
 
         return ret;
@@ -228,7 +247,7 @@ public class NormalDistributionImpl exte
         double ret;
 
         if (p < .5) {
-            ret = getMean();
+            ret = mean;
         } else {
             ret = Double.MAX_VALUE;
         }
@@ -249,11 +268,11 @@ public class NormalDistributionImpl exte
         double ret;
 
         if (p < .5) {
-            ret = getMean() - getStandardDeviation();
+            ret = mean - standardDeviation;
         } else if (p > .5) {
-            ret = getMean() + getStandardDeviation();
+            ret = mean + standardDeviation;
         } else {
-            ret = getMean();
+            ret = mean;
         }
 
         return ret;

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=920852&r1=920851&r2=920852&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 Tue Mar  9 12:53:44 2010
@@ -57,13 +57,17 @@ public interface PascalDistribution exte
      * 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=920852&r1=920851&r2=920852&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 Tue Mar  9 12:53:44 2010
@@ -48,8 +48,8 @@ public class PascalDistributionImpl exte
      */
     public PascalDistributionImpl(int r, double p) {
         super();
-        setNumberOfSuccesses(r);
-        setProbabilityOfSuccess(p);
+        setNumberOfSuccessesInternal(r);
+        setProbabilityOfSuccessInternal(p);
     }
 
     /**
@@ -73,8 +73,19 @@ public class PascalDistributionImpl exte
      * @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(
                   "number of successes must be non-negative ({0})",
@@ -88,8 +99,19 @@ public class PascalDistributionImpl exte
      * @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(
                   "{0} out of [{1}, {2}] range", p, 0.0, 1.0);
@@ -135,8 +157,8 @@ public class PascalDistributionImpl exte
         if (x < 0) {
             ret = 0.0;
         } else {
-            ret = Beta.regularizedBeta(getProbabilityOfSuccess(),
-                getNumberOfSuccesses(), x + 1);
+            ret = Beta.regularizedBeta(probabilityOfSuccess,
+                numberOfSuccesses, x + 1);
         }
         return ret;
     }
@@ -152,9 +174,9 @@ public class PascalDistributionImpl exte
             ret = 0.0;
         } else {
             ret = MathUtils.binomialCoefficientDouble(x +
-                  getNumberOfSuccesses() - 1, getNumberOfSuccesses() - 1) *
-                  Math.pow(getProbabilityOfSuccess(), getNumberOfSuccesses()) *
-                  Math.pow(1.0 - getProbabilityOfSuccess(), x);
+                  numberOfSuccesses - 1, numberOfSuccesses - 1) *
+                  Math.pow(probabilityOfSuccess, numberOfSuccesses) *
+                  Math.pow(1.0 - probabilityOfSuccess, x);
         }
         return ret;
     }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PoissonDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PoissonDistribution.java?rev=920852&r1=920851&r2=920852&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PoissonDistribution.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PoissonDistribution.java Tue Mar  9 12:53:44 2010
@@ -47,7 +47,9 @@ public interface PoissonDistribution ext
      *
      * @param p the mean
      * @throws IllegalArgumentException if p &le; 0
+     * @deprecated as of v2.1
      */
+    @Deprecated
     void setMean(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=920852&r1=920851&r2=920852&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 Tue Mar  9 12:53:44 2010
@@ -121,11 +121,13 @@ public class PoissonDistributionImpl ext
      * @param z a normal distribution used to compute normal approximations.
      * @throws IllegalArgumentException if p &le; 0
      * @since 1.2
+     * @deprecated as of 2.1 (to avoid possibly inconsistent state, the
+     * "NormalDistribution" will be instantiated internally)
      */
+    @Deprecated
     public PoissonDistributionImpl(double p, NormalDistribution z) {
         super();
-        setNormal(z);
-        setMean(p);
+        setNormalAndMeanInternal(z, p);
     }
 
     /**
@@ -134,7 +136,7 @@ public class PoissonDistributionImpl ext
      * @return the Poisson mean for the distribution.
      */
     public double getMean() {
-        return this.mean;
+        return mean;
     }
 
     /**
@@ -143,13 +145,28 @@ public class PoissonDistributionImpl ext
      *
      * @param p the Poisson mean value
      * @throws IllegalArgumentException if p &le; 0
+     * @deprecated as of 2.1 (class will become immutable in 3.0)
      */
+    @Deprecated
     public void setMean(double p) {
+        setNormalAndMeanInternal(normal, p);
+    }
+    /**
+     * Set the Poisson mean for the distribution. The mean value must be
+     * positive; otherwise an <code>IllegalArgument</code> is thrown.
+     *
+     * @param z the new distribution
+     * @param p the Poisson mean value
+     * @throws IllegalArgumentException if p &le; 0
+     */
+    private void setNormalAndMeanInternal(NormalDistribution z,
+                                          double p) {
         if (p <= 0) {
             throw MathRuntimeException.createIllegalArgumentException(
                     "the Poisson mean must be positive ({0})", p);
         }
-        this.mean = p;
+        mean = p;
+        normal = z;
         normal.setMean(p);
         normal.setStandardDeviation(Math.sqrt(p));
     }
@@ -248,9 +265,10 @@ public class PoissonDistributionImpl ext
      *
      * @param value the new distribution
      * @since 1.2
+     * @deprecated as of 2.1 (class will become immutable in 3.0)
      */
+    @Deprecated
     public void setNormal(NormalDistribution value) {
-        normal = value;
+        setNormalAndMeanInternal(value, mean);
     }
-
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/TDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/TDistribution.java?rev=920852&r1=920851&r2=920852&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/TDistribution.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/TDistribution.java Tue Mar  9 12:53:44 2010
@@ -33,7 +33,9 @@ public interface TDistribution extends C
     /**
      * Modify the degrees of freedom.
      * @param degreesOfFreedom the new degrees of freedom.
+     * @deprecated as of v2.1
      */
+    @Deprecated
     void setDegreesOfFreedom(double degreesOfFreedom);
 
     /**

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=920852&r1=920851&r2=920852&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 Tue Mar  9 12:53:44 2010
@@ -44,14 +44,23 @@ public class TDistributionImpl
      */
     public TDistributionImpl(double degreesOfFreedom) {
         super();
-        setDegreesOfFreedom(degreesOfFreedom);
+        setDegreesOfFreedomInternal(degreesOfFreedom);
     }
 
     /**
      * Modify the degrees of freedom.
      * @param degreesOfFreedom the new degrees of freedom.
+     * @deprecated as of 2.1 (class will become immutable in 3.0)
      */
+    @Deprecated
     public void setDegreesOfFreedom(double degreesOfFreedom) {
+        setDegreesOfFreedomInternal(degreesOfFreedom);
+    }
+    /**
+     * Modify the degrees of freedom.
+     * @param degreesOfFreedom the new degrees of freedom.
+     */
+    private void setDegreesOfFreedomInternal(double degreesOfFreedom) {
         if (degreesOfFreedom <= 0.0) {
             throw MathRuntimeException.createIllegalArgumentException(
                   "degrees of freedom must be positive ({0})",
@@ -82,8 +91,8 @@ public class TDistributionImpl
         } else {
             double t =
                 Beta.regularizedBeta(
-                    getDegreesOfFreedom() / (getDegreesOfFreedom() + (x * x)),
-                    0.5 * getDegreesOfFreedom(),
+                    degreesOfFreedom / (degreesOfFreedom + (x * x)),
+                    0.5 * degreesOfFreedom,
                     0.5);
             if (x < 0.0) {
                 ret = 0.5 * t;

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/WeibullDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/WeibullDistribution.java?rev=920852&r1=920851&r2=920852&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/WeibullDistribution.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/WeibullDistribution.java Tue Mar  9 12:53:44 2010
@@ -51,12 +51,16 @@ public interface WeibullDistribution ext
     /**
      * Modify the shape parameter.
      * @param alpha The new shape parameter value.
+     * @deprecated as of v2.1
      */
+    @Deprecated
     void setShape(double alpha);
 
     /**
      * Modify the scale parameter.
      * @param beta The new scale parameter value.
+     * @deprecated as of v2.1
      */
+    @Deprecated
     void setScale(double beta);
 }

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=920852&r1=920851&r2=920852&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 Tue Mar  9 12:53:44 2010
@@ -48,8 +48,8 @@ public class WeibullDistributionImpl ext
      */
     public WeibullDistributionImpl(double alpha, double beta){
         super();
-        setShape(alpha);
-        setScale(beta);
+        setShapeInternal(alpha);
+        setScaleInternal(beta);
     }
 
     /**
@@ -62,7 +62,7 @@ public class WeibullDistributionImpl ext
         if (x <= 0.0) {
             ret = 0.0;
         } else {
-            ret = 1.0 - Math.exp(-Math.pow(x / getScale(), getShape()));
+            ret = 1.0 - Math.exp(-Math.pow(x / scale, shape));
         }
         return ret;
     }
@@ -106,7 +106,7 @@ public class WeibullDistributionImpl ext
         } else  if (p == 1) {
             ret = Double.POSITIVE_INFINITY;
         } else {
-            ret = getScale() * Math.pow(-Math.log(1.0 - p), 1.0 / getShape());
+            ret = scale * Math.pow(-Math.log(1.0 - p), 1.0 / shape);
         }
         return ret;
     }
@@ -114,8 +114,17 @@ public class WeibullDistributionImpl ext
     /**
      * Modify the shape parameter.
      * @param alpha the new shape parameter value.
+     * @deprecated as of 2.1 (class will become immutable in 3.0)
      */
+    @Deprecated
     public void setShape(double alpha) {
+        setShapeInternal(alpha);
+    }
+    /**
+     * Modify the shape parameter.
+     * @param alpha the new shape parameter value.
+     */
+    private void setShapeInternal(double alpha) {
         if (alpha <= 0.0) {
             throw MathRuntimeException.createIllegalArgumentException(
                   "shape must be positive ({0})",
@@ -127,8 +136,17 @@ public class WeibullDistributionImpl ext
     /**
      * Modify the scale parameter.
      * @param beta the new scale parameter value.
+     * @deprecated as of 2.1 (class will become immutable in 3.0)
      */
+    @Deprecated
     public void setScale(double beta) {
+        setScaleInternal(beta);
+    }
+    /**
+     * Modify the scale parameter.
+     * @param beta the new scale parameter value.
+     */
+    private void setScaleInternal(double beta) {
         if (beta <= 0.0) {
             throw MathRuntimeException.createIllegalArgumentException(
                   "scale must be positive ({0})",
@@ -176,6 +194,6 @@ public class WeibullDistributionImpl ext
     @Override
     protected double getInitialDomain(double p) {
         // use median
-        return Math.pow(getScale() * Math.log(2.0), 1.0 / getShape());
+        return Math.pow(scale * Math.log(2.0), 1.0 / shape);
     }
 }

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=920852&r1=920851&r2=920852&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 Tue Mar  9 12:53:44 2010
@@ -45,7 +45,9 @@ public interface ZipfDistribution extend
      *
      * @param n the number of elements
      * @throws IllegalArgumentException if n &le; 0
+     * @deprecated as of v2.1
      */
+    @Deprecated
     void setNumberOfElements(int n);
 
     /**
@@ -62,7 +64,8 @@ public interface ZipfDistribution extend
      *
      * @param s the exponent
      * @throws IllegalArgumentException if s &le; 0.0
+     * @deprecated as of v2.1
      */
+    @Deprecated
     void setExponent(double s);
-
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ZipfDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ZipfDistributionImpl.java?rev=920852&r1=920851&r2=920852&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ZipfDistributionImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ZipfDistributionImpl.java Tue Mar  9 12:53:44 2010
@@ -49,8 +49,8 @@ public class ZipfDistributionImpl extend
      */
     public ZipfDistributionImpl(final int numberOfElements, final double exponent)
         throws IllegalArgumentException {
-        setNumberOfElements(numberOfElements);
-        setExponent(exponent);
+        setNumberOfElementsInternal(numberOfElements);
+        setExponentInternal(exponent);
     }
 
     /**
@@ -69,8 +69,21 @@ public class ZipfDistributionImpl extend
      *
      * @param n the number of elements
      * @exception IllegalArgumentException if n &le; 0
+     * @deprecated as of 2.1 (class will become immutable in 3.0)
      */
-    public void setNumberOfElements(final int n)
+    @Deprecated
+    public void setNumberOfElements(final int n) {
+        setNumberOfElementsInternal(n);
+    }
+    /**
+     * 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
+     * @exception IllegalArgumentException if n &le; 0
+     */
+    private void setNumberOfElementsInternal(final int n)
         throws IllegalArgumentException {
         if (n <= 0) {
             throw MathRuntimeException.createIllegalArgumentException(
@@ -96,8 +109,21 @@ public class ZipfDistributionImpl extend
      *
      * @param s the exponent
      * @exception IllegalArgumentException if s &le; 0.0
+     * @deprecated as of 2.1 (class will become immutable in 3.0)
+     */
+    @Deprecated
+    public void setExponent(final double s) {
+        setExponentInternal(s);
+    }
+    /**
+     * Set the exponent characterising the distribution.
+     * The parameter value must be positive; otherwise an
+     * <code>IllegalArgumentException</code> is thrown.
+     *
+     * @param s the exponent
+     * @exception IllegalArgumentException if s &le; 0.0
      */
-    public void setExponent(final double s)
+    private void setExponentInternal(final double s)
         throws IllegalArgumentException {
         if (s <= 0.0) {
             throw MathRuntimeException.createIllegalArgumentException(
@@ -114,7 +140,7 @@ public class ZipfDistributionImpl extend
      * @return the value of the probability mass function at x
      */
     public double probability(final int x) {
-        if (x <= 0 || x > getNumberOfElements()) {
+        if (x <= 0 || x > numberOfElements) {
             return 0.0;
         }
 
@@ -132,7 +158,7 @@ public class ZipfDistributionImpl extend
     public double cumulativeProbability(final int x) {
         if (x <= 0) {
             return 0.0;
-        } else if (x >= getNumberOfElements()) {
+        } else if (x >= numberOfElements) {
             return 1.0;
         }
 



Mime
View raw message