commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r1159918 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math/stat/regression/SimpleRegression.java site/xdoc/changes.xml
Date Sat, 20 Aug 2011 21:45:53 GMT
Author: psteitz
Date: Sat Aug 20 21:45:53 2011
New Revision: 1159918

URL: http://svn.apache.org/viewvc?rev=1159918&view=rev
Log:
Eliminated extraneous constructor and private field from SimpleRegression.  JIRA: MATH-648.

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/SimpleRegression.java
    commons/proper/math/trunk/src/site/xdoc/changes.xml

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/SimpleRegression.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/SimpleRegression.java?rev=1159918&r1=1159917&r2=1159918&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/SimpleRegression.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/SimpleRegression.java
Sat Aug 20 21:45:53 2011
@@ -60,9 +60,6 @@ public class SimpleRegression implements
     /** Serializable version identifier */
     private static final long serialVersionUID = -3004689053607543335L;
 
-    /** the distribution used to compute inference statistics. */
-    private TDistribution distribution;
-
     /** sum of x values */
     private double sumX = 0d;
 
@@ -93,19 +90,7 @@ public class SimpleRegression implements
      * Create an empty SimpleRegression instance
      */
     public SimpleRegression() {
-        this(1);
-    }
-
-    /**
-     * Create an empty SimpleRegression using the given distribution object to
-     * compute inference statistics.
-     *
-     * @param degrees Number of degrees of freedom of the distribution used
-     * to compute inference statistics.
-     * @since 2.2
-     */
-    public SimpleRegression(int degrees) {
-        distribution = new TDistributionImpl(degrees);
+        super();
     }
 
     /**
@@ -137,10 +122,6 @@ public class SimpleRegression implements
         sumX += x;
         sumY += y;
         n++;
-
-        if (n > 2) {
-            distribution = new TDistributionImpl(n - 2);
-        }
     }
 
 
@@ -169,10 +150,6 @@ public class SimpleRegression implements
             sumX -= x;
             sumY -= y;
             n--;
-
-            if (n > 2) {
-                distribution = new TDistributionImpl(n - 2);
-            }
         }
     }
 
@@ -553,6 +530,7 @@ public class SimpleRegression implements
             throw new OutOfRangeException(LocalizedFormats.SIGNIFICANCE_LEVEL,
                                           alpha, 0, 1);
         }
+        TDistribution distribution = new TDistributionImpl(n - 2);
         return getSlopeStdErr() *
             distribution.inverseCumulativeProbability(1d - alpha / 2d);
     }
@@ -579,6 +557,7 @@ public class SimpleRegression implements
      * @throws MathException if the significance level can not be computed.
      */
     public double getSignificance() throws MathException {
+        TDistribution distribution = new TDistributionImpl(n - 2);
         return 2d * (1.0 - distribution.cumulativeProbability(
                     FastMath.abs(getSlope()) / getSlopeStdErr()));
     }

Modified: commons/proper/math/trunk/src/site/xdoc/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/site/xdoc/changes.xml?rev=1159918&r1=1159917&r2=1159918&view=diff
==============================================================================
--- commons/proper/math/trunk/src/site/xdoc/changes.xml (original)
+++ commons/proper/math/trunk/src/site/xdoc/changes.xml Sat Aug 20 21:45:53 2011
@@ -52,6 +52,9 @@ The <action> type attribute can be add,u
     If the output is not quite correct, check for invisible trailing spaces!
      -->
     <release version="3.0" date="TBD" description="TBD">
+      <action dev="psteitz" type="update" issue="MATH-648">
+         Eliminated extraneous constructor from SimpleRegression.
+      </action>
       <action dev="psteitz" type="update" issue="MATH-506">
          Eliminated pluggability of ChiSquaredDistribution used by ChiSquaredDistributionTest.
       </action>



Mime
View raw message