Restored some double casts to improve ensure correctness does not depend on order of operations or literal conversion, dropped uneccesary parens.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@764208 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b6703d294c
commit
4095d7a029
|
@ -124,9 +124,9 @@ public class SimpleRegression implements Serializable {
|
|||
} else {
|
||||
double dx = x - xbar;
|
||||
double dy = y - ybar;
|
||||
sumXX += dx * dx * n / (n + 1.0);
|
||||
sumYY += dy * dy * n / (n + 1.0);
|
||||
sumXY += dx * dy * n / (n + 1.0);
|
||||
sumXX += dx * dx * (double) n / (n + 1d);
|
||||
sumYY += dy * dy * (double) n / (n + 1d);
|
||||
sumXY += dx * dy * (double) n / (n + 1d);
|
||||
xbar += dx / (n + 1.0);
|
||||
ybar += dy / (n + 1.0);
|
||||
}
|
||||
|
@ -157,9 +157,9 @@ public class SimpleRegression implements Serializable {
|
|||
if (n > 0) {
|
||||
double dx = x - xbar;
|
||||
double dy = y - ybar;
|
||||
sumXX -= dx * dx * n / (n - 1.0);
|
||||
sumYY -= dy * dy * n / (n - 1.0);
|
||||
sumXY -= dx * dy * n / (n - 1.0);
|
||||
sumXX -= dx * dx * (double) n / (n - 1d);
|
||||
sumYY -= dy * dy * (double) n / (n - 1d);
|
||||
sumXY -= dx * dy * (double) n / (n - 1d);
|
||||
xbar -= dx / (n - 1.0);
|
||||
ybar -= dy / (n - 1.0);
|
||||
sumX -= x;
|
||||
|
@ -468,7 +468,7 @@ public class SimpleRegression implements Serializable {
|
|||
*/
|
||||
public double getInterceptStdErr() {
|
||||
return Math.sqrt(
|
||||
getMeanSquareError() * ((1d / n) + (xbar * xbar) / sumXX));
|
||||
getMeanSquareError() * ((1d / (double) n) + (xbar * xbar) / sumXX));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -589,7 +589,7 @@ public class SimpleRegression implements Serializable {
|
|||
* @return the intercept of the regression line
|
||||
*/
|
||||
private double getIntercept(double slope) {
|
||||
return (sumY - slope * sumX) / (n);
|
||||
return (sumY - slope * sumX) / n;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue