calculate method

void calculate()

Implementation

void calculate() {
  var a = 0.0;
  var b1 = 0.0;
  var b2 = 0.0;
  var c = 0.0;

  for (var i = 0; i < xyList.length; i++) {
    var x = xyList[i][0];
    var y = xyList[i][1];
    a = a + x * y;
    b1 += x;
    b2 += y;

    c += pow(x, 2);
  }
  a = 3 * a;
  var b = b1 * b2;
  c = 3 * c;
  var d = pow(b1, 2);

  _slope = (a - b) / (c - d);

  var e = b2;
  var f = _slope * b1;

  _yIntercept = (e - f) / xyList.length;
}