Simplified code, eliminated unecessary parameters in private methods.

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk@365298 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Phil Steitz 2006-01-02 05:55:30 +00:00
parent 037327ba19
commit 61f59a02e6
1 changed files with 4 additions and 29 deletions

View File

@ -246,7 +246,7 @@ public class SimpleRegression implements Serializable {
* @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 class SimpleRegression implements Serializable {
*/
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 @@ public class SimpleRegression implements Serializable {
* @return r-square
*/
public double getRSquare() {
return getRSquare(getSlope());
double ssto = getTotalSumSquares();
return (ssto - getSumSquaredErrors()) / ssto;
}
/**
@ -481,32 +482,6 @@ public class SimpleRegression implements Serializable {
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;
}
/**
* Computes SSR from b1.
*