rem: this.Xavg += X[i]; this.Yavg += Y[i]; } this.Xavg /= length; this.Yavg /= length;  var sumXdiffYdiff = 0; var sumXdiffsquared = 0; var sumYdiffsquared = 0;  for (i = 0; i < length; i++) { var xDiff = (X[i] - this.Xavg); var yDiff = (Y[i] - this.Yavg);  sumXdiffYdiff   += xDiff * yDiff; sumXdiffsquared += xDiff * xDiff; sumYdiffsquared += yDiff * yDiff; 
add: SUM_X  += X[i]; SUM_XY += X[i]*Y[i]; SUM_XX += X[i]*X[i]; SUM_Y  += Y[i]; SUM_YY += Y[i]*Y[i]; 
context:   function LinearRegression(data)    {      // http://www.bearcave.com/misl/misl_tech/wavelets/stat/      /*        X0,X1...; Y0,Y1,...        b = sum( (Xi - Xavg)(Yi - Yavg) ) / sum ( (Xi - Xavg)*(Xi - Xavg) )        a = Yavg - b * Xavg        stddev*stddev = (sum( (Yi - Yavg) * (Yi - Yavg) ) -         b * sum( (Xi - Xavg)*(Yi - Yavg) ) ) /        sum ( (Xi - Xavg) * (Xi - Xavg) )      */      var i;      if (data.X.length != data.Y.length)      {        throw 'LinearRegression: data point length mismatch';      }      if (data.X.length < 2)      {        throw 'LinearRegression: data point length < 2';      }      var length = data.X.length;      var X = data.X;      var Y = data.Y;      this.Xavg = 0;      this.Yavg = 0;      for (i = 0; i < length; i++)      {        this.Xavg += X[i];        this.Yavg += Y[i];      }      this.Xavg /= length;      this.Yavg /= length;      var sumXdiffYdiff = 0;      var sumXdiffsquared = 0;      var sumYdiffsquared = 0;      for (i = 0; i < length; i++)      {        var xDiff = (X[i] - this.Xavg);        var yDiff = (Y[i] - this.Yavg);        sumXdiffYdiff   += xDiff * yDiff;        sumXdiffsquared += xDiff * xDiff;         sumYdiffsquared += yDiff * yDiff;      }      this.b = sumXdiffYdiff / sumXdiffsquared;      this.a = this.Yavg - this.b * this.Xavg;      // standard deviation of regression      this.sigma = Math.sqrt( (sumYdiffsquared - this.b * sumXdiffYdiff) /                               (length - 2));      // standard error in b      this.SE = this.sigma / Math.sqrt(sumXdiffsquared);    }
meta: 8395	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/8395/0c224a23a1a1941a55f278c5b505f75c385066c0/shell.js/buggy/js/tests/js1_6/shell.js