Skip to content

Commit

Permalink
MONDRIAN
Browse files Browse the repository at this point in the history
       The forcast y-axis must have the same number of entries as the data.
       If there is an x value missing, put an empty y value into the
       forcast. If this is not done, one gets a discontinuity in the 
       forecast line for each missing data entry.

[git-p4: depot-paths = "//open/mondrian/": change = 4995]
  • Loading branch information
Richard Emberson committed Jan 9, 2006
1 parent 674aeb1 commit 85ef3f9
Showing 1 changed file with 33 additions and 7 deletions.
40 changes: 33 additions & 7 deletions src/main/mondrian/olap/fun/LinReg.java
Expand Up @@ -433,8 +433,17 @@ public static LinReg.Value accuracy(LinReg.Value value) {
Iterator ityf = yfs.iterator();
while (ity.hasNext()) {
// Get next data point
double y = ((Double) ity.next()).doubleValue();
double yf = ((Double) ityf.next()).doubleValue();
Double dy = (Double) ity.next();
if (dy == null) {
continue;
}
Double dyf = (Double) ityf.next();
if (dyf == null) {
continue;
}

double y = dy.doubleValue();
double yf = dyf.doubleValue();

// Calculate error in forecast, and update sums appropriately

Expand Down Expand Up @@ -480,8 +489,17 @@ public static LinReg.Value accuracy(LinReg.Value value) {
ityf = yfs.iterator();
while (ity.hasNext()) {
// Get next data point
double y = ((Double) ity.next()).doubleValue();
double yf = ((Double) ityf.next()).doubleValue();
Double dy = (Double) ity.next();
if (dy == null) {
continue;
}
Double dyf = (Double) ityf.next();
if (dyf == null) {
continue;
}

double y = dy.doubleValue();
double yf = dyf.doubleValue();

double error = yf - y;
SSE += (error - MSE)*(error - MSE);
Expand Down Expand Up @@ -549,9 +567,17 @@ public static List forecast(LinReg.Value value) {

Iterator it = value.xs.iterator();
while (it.hasNext()) {
double x = ((Double) it.next()).doubleValue();
double yf = value.intercept + value.slope * x;
yfs.add(new Double(yf));
Double d = (Double) it.next();
// If the value is missing we still must put a place
// holder in the y axis, otherwise there is a discontinuity
// between the data and the fit.
if (d == null) {
yfs.add(null);
} else {
double x = d.doubleValue();
double yf = value.intercept + value.slope * x;
yfs.add(new Double(yf));
}
}

return yfs;
Expand Down

0 comments on commit 85ef3f9

Please sign in to comment.