commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r365298 - /jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/regression/SimpleRegression.java
Date Mon, 02 Jan 2006 05:55:32 GMT
Author: psteitz
Date: Sun Jan  1 21:55:30 2006
New Revision: 365298

URL: http://svn.apache.org/viewcvs?rev=365298&view=rev
Log:
Simplified code, eliminated unecessary parameters in private methods.

Modified:
    jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/regression/SimpleRegression.java

Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/regression/SimpleRegression.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/regression/SimpleRegression.java?rev=365298&r1=365297&r2=365298&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/regression/SimpleRegression.java
(original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/regression/SimpleRegression.java
Sun Jan  1 21:55:30 2006
@@ -246,7 +246,7 @@
      * @return sum of squared errors associated with the regression model
      */
     public double getSumSquaredErrors() {
-        return getSumSquaredErrors(getSlope());
+        return sumYY - sumXY * sumXY / sumXX;
     }
 
     /**
@@ -319,7 +319,7 @@
      */
     public double getR() {
         double b1 = getSlope();
-        double result = Math.sqrt(getRSquare(b1));
+        double result = Math.sqrt(getRSquare());
         if (b1 < 0) {
             result = -result;
         }
@@ -341,7 +341,8 @@
      * @return r-square
      */
     public double getRSquare() {
-        return getRSquare(getSlope());
+        double ssto = getTotalSumSquares();
+        return (ssto - getSumSquaredErrors()) / ssto;
     }
 
     /**
@@ -479,32 +480,6 @@
     */
     private double getIntercept(double slope) {
         return (sumY - slope * sumX) / ((double) n);
-    }
-
-    /**
-     * Returns the sum of squared errors associated with the regression 
-     * model, using the slope of the regression line. 
-     * <p> 
-     * Returns NaN if the slope is NaN.
-     * 
-     * @param b1 current slope
-     * @return sum of squared errors associated with the regression model
-     */
-    private double getSumSquaredErrors(double b1) {
-        return sumYY - sumXY * sumXY / sumXX;
-    }
-
-    /** 
-     * Computes r-square from the slope.
-     * <p>
-     * will return NaN if slope is Nan.
-     *
-     * @param b1 current slope
-     * @return r-square
-     */
-    private double getRSquare(double b1) {
-        double ssto = getTotalSumSquares();
-        return (ssto - getSumSquaredErrors(b1)) / ssto;
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message